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:
- Set the Chrome driver to system property, I checked the path is correct.
- Set the capabilities
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