rakeshghl44
rakeshghl44

Reputation: 21

SessionNotCreatedException: session not created exception from unknown error: Runtime.executionContextCreated has invalid 'context' with Chrome driver

Runtime error

Actual Code

Error stack trace (Updated from comments):

Starting ChromeDriver 2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067) on port 7778 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': {"auxData":{"frameId":"961185F0AA38D24650EF6C797BC32535","isDefault":true,"type":"default"},"id":1,"name":"","origin":"://"} 
(Session info: chrome=70.0.3538.102) 
(Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information) 
Command duration or timeout: 1.68 seconds Build info: version: '3.141.5', revision: 'd54ebd709a', time: '2018-11-06T11:58:41' 
System info: host: 'LTAH024', ip: '192.168.131.142', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_60' 
Driver info: driver.version: ChromeDriver

I wrote simple program to launching a chrome browser. Please see the below code. I have already set a path in environment variable:

package automationFramework;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class ChromeBrowser {

  public static void main(String[] args) {
    // TODO Auto-generated method stub

    WebDriver drive = new ChromeDriver();

    drive.get("http://toolsqa.com/selenium-webdriver/running-tests-in-chrome-browser/");

    System.out.println("Successfully open tools qa website in Chrome browser");
    //Thread.sleep(5000); //To initiate thread , we need to add throws interrupt exception

    //Close the driver
    //driver.quit();
  }
}

Please look into this and help me out. The same thing geckodriver for firefox is working.

Upvotes: 2

Views: 10717

Answers (3)

undetected Selenium
undetected Selenium

Reputation: 193338

This error message...

Starting ChromeDriver 2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067) on port 7778 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': {"auxData":{"frameId":"961185F0AA38D24650EF6C797BC32535","isDefault":true,"type":"default"},"id":1,"name":"","origin":"://"} 
(Session info: chrome=70.0.3538.102) 
(Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information) 
Command duration or timeout: 1.68 seconds Build info: version: '3.141.5', revision: 'd54ebd709a', time: '2018-11-06T11:58:41' 
System info: host: 'LTAH024', ip: '192.168.131.142', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_60' 
Driver info: driver.version: ChromeDriver

...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.

You have 3 issues exactly and your main issue is the incompatibility between the version of the binaries you are using as follows:

  • You are using chromedriver=2.2.20
  • Release Notes of chromedriver=2.20 clearly mentions the following :

Supports Chrome v43-48

  • You are using chrome=70.0
  • Release Notes of ChromeDriver v2.43 clearly mentions the following :

Supports Chrome v69-71

  • Your Selenium Client version is the current version of 3.141.5..
  • Your JDK version is 1.8.0_60 which is pretty ancient.

So there is a clear mismatch between the JDK v8u60 , Selenium Client v3.141.5 , ChromeDriver v2.20 and the Chrome Browser v70.0

Solution

  • While using Selenium v3.x clients you need to download the latest ChromeDriver from ChromeDriver - WebDriver for Chrome store it anywhere within your system and provide the absolute path of the ChromeDriver through System.setProperty() line as follows:

    System.setProperty("webdriver.chrome.driver", "C:\\path\\to\\chromedriver.exe");
    
  • Upgrade JDK to recent levels JDK 8u191.

  • Upgrade ChromeDriver to current ChromeDriver v2.43 level.
  • Keep Chrome version between Chrome v69-71 levels. (as per ChromeDriver v2.43 release notes)
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • (WindowsOS only) Use CCleaner tool to wipe off all the OS chores before and after the execution of your Test Suite.
  • (LinuxOS only) Free Up and Release the Unused/Cached Memory in Ubuntu/Linux Mint before and after the execution of your Test Suite.
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
  • Take a System Reboot.
  • Execute your @Test.
  • Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

Upvotes: 1

koushick
koushick

Reputation: 497

Their are Three Ways to open The Chrome Browser:

First one:using system.setproperty

System.setProperty("webdriver.chrome.driver", "F:\\New folder\\chromedriver.exe");
Webdriver driver = new ChromeDriver();

Second one : using Chrome Options:

//set path to chromedriver.exe

        ChromeOptions options = new ChromeOptions();
        options.setAcceptInsecureCerts(true);
        options.setBinary(new File("C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"));
        options.addArguments("disable-infobars");
        System.setProperty("webdriver.chrome.driver", "F:\\New folder\\chromedriver.exe");

        driver = new ChromeDriver(options);

Last one : if you are using maven use this

This downloads the latest chrome driver version and starts it. You can use WebDriverManager within using bonigarcia dependency. Add The bonigarcia dependency in your Pom.xml File and start using it via WebdriverManager

https://github.com/bonigarcia/webdrivermanager

WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();

Finally What is Version for your Gecko driver & Firefox?

Upvotes: 0

Al Imran
Al Imran

Reputation: 882

Download chrome driver, keep it at your local and put the path at System.setProperty try the below code, hope it helps.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class ChromeBrowser {
    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver", "B:\\chromedriver.exe"); //put driver path here
        WebDriver drive = new ChromeDriver();

        drive.get("http://toolsqa.com/selenium-webdriver/running-tests-in- chrome-browser/");
        System.out.println("Successfully open tools qa website in Chrome browser");
        drive.quit();
    }
}

Upvotes: 0

Related Questions