0

I am new on using Selenium and I faced some questions on using RemoteWebDriver in Selenium Grid 2. I would like to what's wrong in my code. Thanks.

I set the RemoteWebDriver in 3 steps:

  1. Set the Chrome driver to system property, I checked the path is correct.
  2. Set the capabilities
  3. Turn on the driver by RemoteWebDriver

        logger.info("1. Start");
    
        File file = new File("/path/of/chromedriver");
        System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
    
        logger.info("2. Get Path: " + file.getAbsolutePath());
    
        DesiredCapabilities caps = new DesiredCapabilities();
        caps.setBrowserName(DesiredCapabilities.chrome().getBrowserName());
    
        logger.info("3. Set capabilities: " + caps);
    
        URL url = new URL(URL);
        RemoteWebDriver driver = new RemoteWebDriver(url, caps);
    
        logger.info("4. Initialize driver: " + driver);
        logger.info("5. End");
    
        return driver;
    

The result pass first 2 steps but fail in the last step because the log does not show. It seems there is a problem in setting RemoteWebDriver. The log is shown as below:


May 16, 2017 8:28:16 PM com.test.Setup setupDriver INFO: 1. Start

May 16, 2017 8:28:16 PM com.test.Setup setupDriver INFO: 2. Get Path: /path/of/chromedriver

May 16, 2017 8:28:16 PM com.test.Setup setupDriver INFO: 3. Set capabilities: Capabilities [{browserName=chrome}]

May 16, 2017 8:28:16 PM com.test.Setup setupDriver SEVERE: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html


Can anyone suggest where is the problem, thanks!

selenium-server-standalone-3.4.0.jar

selenium-java-3.4.0

chromedriver 2.29

java version "1.8.0_111"

TestNG

user2504831
  • 147
  • 1
  • 3
  • 11

1 Answers1

0

The exception says it all.

May 16, 2017 8:28:16 PM com.test.Setup setupDriver SEVERE: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html

Please ensure you do the following on the machine in which you are running the node.

  • Have the location of the chromedriver binary made available as part of your PATH environment variable.
  • Now to ensure that the location is properly set, open up a new command prompt/terminal and type chromedriver.

You should see an output as below (my output is from a MAC)

12:16 $ chromedriver
Starting ChromeDriver 2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b) on port 9515
Only local connections are allowed.

Once you see a similar output, you can try running your test again and you should be fine.

Krishnan Mahadevan
  • 14,121
  • 6
  • 34
  • 66
  • Thank you for your reply. I have added the driver to bash_profile and run it, i.e. export chromedriver="/path/of/chromedriver", and above message can be seen after typing $chromedriver in terminal. However, the issue is still here. Also, i have set property in the code, i.e. System.setProperty("webdriver.chrome.driver", file.getAbsolutePath()); Could you suggest any other way to check where is the problem? Thanks – user2504831 May 17 '17 at 09:25
  • Updated the bash_profile: export chromedriver="/path/of/chromedriver"; export PATH=$chromedriver:$PATH But it is still fail, same error message shown – user2504831 May 17 '17 at 09:45