Chrome WebDriver Test with Selenium Java API


How to create a test program using Chrome WebDriver with Selenium Java API?



Here is a simple test program that the Chrome WebDriver Test with the Selenium Java API:

C:\fyicenter> type

import org.openqa.selenium.*;
public class ChromeTest {
  public static void main(String[] args) {
     WebDriver driver = new ChromeDriver();

Compile and run it with the Selenium Client JAR file:

C:\fyicenter> javac -classpath \
   \fyicenter\selenium\java\client-combined-3.141.59.jar \

C:\fyicenter> java -classpath \
   \fyicenter\selenium\java\libs\commons-exec-1.3.jar \

Starting ChromeDriver 2.16.333243 (0bfa1d3575fc1044244f21ddb82bf870944ef961) on port 44239
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created exception
from unknown error: Runtime.executionContextCreated has invalid 'context': 
  (Session info: chrome=74.0.3729.169)
  (Driver info: chromedriver=2.16.333243 (0bfa1d3575fc1044244f21ddb82bf870944ef961),platform=Windows NT 10.0 x86_64) 
  (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 3.21 seconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '12.0.1'
Driver info: driver.version: ChromeDriver
   at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
   at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(
   at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(
   at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(
   at java.base/java.lang.reflect.Constructor.newInstance(
   at org.openqa.selenium.remote.ErrorHandler.createThrowable(
   at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(

As you can see, we are not able to create the session: "session not created exception". The default ChromeDriver version is 2.16, which is not compatible with Selenium WebDriver 3.141. See next tutorial on how to fix it.


⇒ Use Chrome WebDriver with Google ChromeDriver

⇐ Compatibility of Selenium Client Java API and JDK

⇑ Starting with Selenium WebDriver Client Java API

⇑⇑ Selenium Tutorials

2020-02-07, 1653👍, 0💬