Akash Dugam Akash Dugam - 18 days ago 6
Java Question

Selenium Configuration with Eclipse

I'm trying to run simple selenium webdriver case on Eclipse but it's throwing errors.

My code:

package automationFramework;



import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;


public class Demo {

public static void main(String[] args) {

String MyURL = "http://www.google.com";

WebDriver driver = new FirefoxDriver();
driver.get(MyURL);

//close Firefox
driver.close();

// exit the program explicitly
System.exit(0);

}

}


Following lines are errors.

Exception in thread "main" org.openqa.selenium.WebDriverException: Cannot find firefox binary in PATH. Make sure firefox is installed. OS appears to be: VISTA
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'
System info: host: 'VW003419', ip: '10.68.30.32', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.firefox.internal.Executable.<init>(Executable.java:74)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:60)
at org.openqa.selenium.firefox.FirefoxBinary.<init>(FirefoxBinary.java:56)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:120)
at automationFramework.Demo.main(Demo.java:16)


It's happening with chrome as well. I have installed it on default location.

Answer

Please try to open chrome like below

// call the Chrome driver as below first 
System.setProperty("webdriver.chrome.driver", "D:\\eclipseProject\\##\\src\\com\\##\\chromedriver_win32\\chromedriver.exe");
// path to chrome exe that you have downloaded form given url (below)
driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://www.seleniumhq.com"); // link to your web-table web page

// download chrome exe form this link http://docs.seleniumhq.org/download/