I am running the following but getting the error
public class base
{
public static WebDriver driver;
public static void main(String[] args) throws
The error does gives us a hint about what is going wrong as follows :
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new service: ChromeDriverService
: Unable to create new service: ChromeDriverService which means the new session wasn't initiated.Driver info: driver.version: unknown
: driver.version: unknown means the chromedriver binary wasn't invoked at all.at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
: sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) which stems out from either of the following :
java.lang.RuntimeException: exception in constructor
: Occurance of this exception is unique to reflection. Normally, it is impossible to write code which ignores a checked exception as it would not compile at all.
java.lang.reflect.InvocationTargetException
: If an InvocationTargetException
is thrown that means the method was invoked. This exception does not indicate a problem with the reflection package or its usage.
java.lang.IllegalArgumentException
: An IllegalArgumentException
is thrown if the constructor was passed an argument of the wrong type.
From the above mentioned ponints it is pretty clear that the version of Selenium-Java
client, JDK
, ChromeDriver
binary and Chrome
are not compatible.
The solution would be as follows :
JDK
with the recent releases (JDK 8u152)Selenium-Java
client with the recent releases (Selenium-Java v3.8.1)ChromeDriver
binary with the recent releases (ChromeDriver v2.34)ChromeDriver
binary with the recent releases (Chrome v63.0)Please do the following and retry.
Ensure that the path C:\\code\\lib\\browser drivers\\chromedriver.exe
is added to your %PATH%
variable on the machine in which you are running the node. This would ensure that the selenium uber jar can find the location of the chromedriver binary.
System.setProperty("webdriver.chrome.driver", "C:\code\lib\browser drivers\chromedriver.exe");
This mechanism should be only used when you are doing
ChromeDriver driver = ChromeDriver()
Since you are working with a selenium grid, you are dealing with multiple JVMs here.
System.setProperty()
will affect only the current JVM (which in this case is your tests), but the actual browser gets spun off in a different JVM (the one that is running the selenium node).