0
votes

I am trying to run my test cases on Chrome and I had copied the path in the Properties file,but still console is throwing annoying statements like: ERROR: The path to the chromedriver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromium/downloads/list FAILED CONFIGURATION: @BeforeTest startWebSession java.lang.NullPointerException

5

5 Answers

3
votes

One thing I have found is that the Chrome driver cannot be started from within Eclipse. It must be run from a command prompt. At least on Windows 7 64-bit.

Trying to run it from within Eclipse produces this exception:

Exception in thread "main" java.lang.IllegalStateException: The webdriver.chrome.driver system property defined chromedriver executable does not exist: C:\Windows\System32\chromedriver.exe

This problem only occurs for Chrome. IE and FireFox work fine from within Eclipse.

2
votes

Download the chrome driver from http://code.google.com/p/chromedriver/downloads/list

Initialize your driver object in the following manner -

System.setProperty("webdriver.chrome.driver","C:\\chromedriver.exe");

    WebDriver driver = new ChromeDriver();

By doing this the chrome driver works properly.

0
votes

This is how do I initialize the ChromeDriver:

public RegulationUI() throws Exception{
   ChromeDriverService service = ChromeDriverService.createDefaultService();
   File file = new File(RegulationUI.class.getResource("/chromedriver.exe").toURI());
   System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, file.getAbsolutePath());                
   ChromeOptions options = new ChromeOptions();
   options.addArguments("--start-maximized");
   driver = new ChromeDriver(service,options);
}

BTW my test class is named RegulationUI

Try this, it works for me and moreover, I know that this is "multicomputer" solution - our project is in subversion and this way everybody can run it, even if we have differently setup where exactly on disk the "working folder" for IDE is

0
votes
    Please download chromedriver.exe for Google chrome browser 
    please download IEdriver.exe for Internet explore.

Please And kept these files in a root folder of windows for simplicity. Lets consider your operating systems installed on c:\ (C Driver) create a folder name Selenium on C-Drive and Kept these binary(.exe) files. like c:\selenium

    in your Testcase/testScript Write as 

    //For Chrome Browser:
    Webdriver driver = new ChromeDriver();
    java.io.File file = new File("c:\\selenium\\chromedriver.exe");     
    System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
0
votes

If you are using maven then try to use following in your pom:

    <dependency>
        <groupId>io.github.bonigarcia</groupId>
        <artifactId>webdrivermanager</artifactId>
        <version>RELEASE</version>
    </dependency> 

and use it like this for chrome in your setup:

    ChromeDriverManager.getInstance().setup();
    driver = new ChromeDriver();