How to get Firefox working with Selenium WebDriver on Mac OSX?

SeleniumAutomation TestingTesting Tools

We can get Firefox working with Selenium webdriver on Mac OS. For Firefox versions which are greater than 47, the geckodriver.exe file is to be used. We shall be able to launch the browser only after creating an object of the FirefoxDriver class.

Syntax

WebDriver driver=new FirefoxDriver();

Visit the link −  https://www.selenium.dev/downloads/ and go to the Browser segment. Click on the Documentation link below Firefox.

In the Supported platforms page, click on geckodriver releases link.

Then click on the link corresponding to Mac OS.

Once downloaded, extract the file and save the geckodriver.exe file to the /usr/local/bin location. As in Windows, we do not need to configure any path of the file in Mac.

Example

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.concurrent.TimeUnit;
public class FirefoxOnMac{
   public static void main(String[] args) {
      WebDriver driver = new FirefoxDriver();
      driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS);
      driver.get("https://www.tutorialspoint.com/index.htm");
      driver.quit();
   }
}
raja
Published on 01-Feb-2021 11:41:39
Advertisements