0
votes

For ex my chrome when dropped in the commpand prompt gives me the path - /Applications/Google\ Chrome.app

I set

System.setProperty("webdriver.chrome.driver", "/Applications/Google/Chrome.app"); WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");

But it doesnt work, same with firefox. I used a lot of suggestions already given but none seems to work. Can someone pls let me know if there is something to be added?

3

3 Answers

0
votes

Why have you used "/Applications/Google/Chrome.app". You would need to provide the path of the driver only, not the browser. Below is the code for Firefox, but you would need to download and configure GeckoDriver (for latest version of FF and Selenium 3.x)

public class FirefoxTest {

@Test
public void FirefoxTest_Test1() {
    System.setProperty("webdriver.gecko.driver","D:\\Firefox\\geckodriver.exe");
    FirefoxDriver driver = new FirefoxDriver();
    driver.get("http://www.google.com");
}
}

Check this link for complete details for downloading and setup of Geckodriver with Firefox - http://automationtestinghub.com/selenium-3-0-launch-firefox-with-geckodriver/

0
votes

For Chrome: Need to Download fresh Chrome Driver from http://chromedriver.storage.googleapis.com/index.html?path=2.24/ and mention local system path up to chomedriver.exe

System.setProperty("webdriver.chrome.driver","G:\\ravik\\Ravi-Training\\Selenium\\Drivers\\cd\\chromedriver.exe");
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    ChromeDriver d1 = new ChromeDriver(capabilities);

For FF: if your firefox version is latest(46.0 or above) then user geckodriver along with selenium 2.53.0 jar files. download geckodriver form https://github.com/mozilla/geckodriver/releases and then save it as "wires" in your local system. mention local system path up to wires.

System.setProperty("webdriver.gecko.driver", "G:\\ravik\\Ravi-Training\\Selenium\\Marionette for firefox\\wires.exe");
    WebDriver driver = new MarionetteDriver();

Hope this could be helpful.

0
votes

The easiest way to use chrome driver is.. download and place the driver into the bin folder of your project. no need to set the path of the driver location