How to solve sessionnotcreated issue in Selenium webdriver for Chrome browser? - java

I am trying to launch Chrome browser but getting an error of "session not created" in Selenium. It research on it and I found if the browser and Chrome driver is not compatible then we will get such issue, so download the latest version of Chrome Driver i.e. Chrome Driver 2.45 which is compatible with v70-72.
So I have downloaded browser version 70.0.3538.67, but still I am unable to launch the Chrome browser and getting the same error. I am using Eclipse 2018-09 and selenium-server-standalone-3.141.59. Below is my code and error message:
Code:-
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class open_browser {
public WebDriver driver;
public void aa1() {
System.setProperty("webdriver.chrome.driver", "F:\\Selenium
files\\chromedriver.exe");
driver= new ChromeDriver();
driver.get("google.com");
}
public static void main(String[] args) {
// TODO Auto-generated method stub
open_browser ob=new open_browser();
ob.aa1();
}
}
Error message:-
Starting ChromeDriver 2.45.615291
(ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387)
on port 48165
Only local connections are allowed.
Exception in thread "main" >org.openqa.selenium.SessionNotCreatedException:
session not created
from disconnected: unable to connect to renderer
(Session info: chrome=70.0.3538.67)
(Driver info: chromedriver=2.45.615291
(ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387),platform=Windows NT 6.1.7601 SP1
x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 3.56 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30
17:32:46'
System info: host: 'aspirehp-PC', ip: '192.168.43.104', os.name: 'Windows
7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:144)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:170)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:159)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:116)
at practise.open_browser.aa1(open_browser.java:10)
at practise.open_browser.main(open_browser.java:17)

Go for all latest one's.
Latest chrome browser (as admin to system, generally install in C:\Program Files (x86))
Latest chromedriver http://chromedriver.chromium.org/downloads presently ChromeDriver 2.45
Latest webdriver https://www.seleniumhq.org/download/ presently 3.141.59
Also update the get, need to provide complete URL , like
System.setProperty("webdriver.chrome.driver", "E:\\workspace\\Training\\drivers\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("http://www.google.com");

Related

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

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.
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.
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();
}
}
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?

Unable to start Chrome browser with user profile in Selenium

I am trying to open a Chrome browser window with an existing user profile.
String dir= "/Users/labuser/Library/Application Support/Google/Chrome";
ChromeOptions options = new ChromeOptions();
options.addArguments("--user-data-dir="+dir);
driver = new ChromeDriver(options); // throws an exception!
I confirmed the user directory path by looking at chrome://version page. (screenshot below)
Due to some reason, this code throws an exception with very less information
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2),platform=Mac OS X 10.12.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.33 seconds
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'arustagi-wx-3', ip: '10.41.25.35', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:148)
Edit
I am using the following chrome browser, this falls in the supported range of browsers
Version 61.0.3163.100
You are using the latest version of the ChromeDriver
chromedriver=2.33.506106
with Selenium 2.53. You should use the latest release.
Anyway, what is your browser version? Here you can take a look which are the browsers version supported (based on your chromedriver).
EDIT
I tried with:
Selenium 3.5.3
ChromeDriver v2.33
Google Chrome Version 62.0.3202.62 (Official Build) (64-bit)
From chrome://version/, my profile path is
/Volumes/MacintoshSSD/Users/DurdenP/Library/Application Support/Google/Chrome/Default
Trying
String chromeDriver ="pathTo/ChromeDriver/chromedriver";
System.setProperty("webdriver.chrome.driver", chromeDriver);
ChromeOptions options = new ChromeOptions();
String dir= "/Volumes/MacintoshSSD/Users/DurdenP/Library/Application Support/Google/Chrome";
options.addArguments("user-data-dir="+dir);
ChromeDriver driver = new ChromeDriver(options);
it works.
Finally got this fixed. I was working on macOS and found out that i needed to quit the browser cleanly.
After closing the browser window, i had to right click on the icon in the dock and press quit. The selenium script would work perfectly fine after this.

Microsoft Edge: org.openqa.selenium.remote.SessionNotFoundException: null

Automating tests to edge browser through webDriver using java script.
System.setProperty("webdriver.edge.driver",
"C:\\Program Files (x86)\\Microsoft Web Driver\\MicrosoftWebDriver.exe");
WebDriver driver = new EdgeDriver();
Already install MicrosoftWebDriver
And using selenium webdriver 2.48.2
OS: Microsoft Windows [Version 10.0.10565]
But got and Exception:
Exception in thread "main"
org.openqa.selenium.remote.SessionNotFoundException: null (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.14 seconds
Build info: version: '2.48.2', revision: '41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09 13:08:06'
System info: host: 'DESKTOP-DUHBOA4', ip: '192.168.31.26', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_45'
Driver info: org.openqa.selenium.edge.EdgeDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:164)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:129)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:152)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:141)
at org.openqa.selenium.edge.EdgeDriver.<init>(EdgeDriver.java:98)
at test.edge.browser.UseEdgeBrowser.main(UseEdgeBrowser.java:18)
No clue for this. Do I still need to configure something?
There are 2 kinds of
1. Microsoft WebDriver: https://www.microsoft.com/en-us/download/details.aspx?id=48212
and
WebDriver for Windows Insiders: http://www.microsoft.com/en-us/download/details.aspx?id=48740
using 1 with this issue. using 2 works for me
It's some time ago, but here is the solution for everyone with the same error..
Your Windows build must be equal to the Microsoft WebDriver version(eg 14393). Just open start menu, type in "winver" and use the correct WebDriver (right hand side) on following page:
https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

Selenium Can't open IE10 in windows 7 server by write Selenium Code

I received error message with new windows as "Internet explorer has stopped working "
I tried by enable/disable protect mode for all zones , google help solutions . I download IEDriverServer_x64_2.42.0 and selenium-java-2.42.2. I have added jar files from selenium 2.4.2 to my project library by add build path .
my code is :
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
capabilities.setPlatform(Platform.WINDOWS);
capabilities.setCapability("silent", true);
System.setProperty("webdriver.ie.driver", "C:\\IEDriverServer_x64_2.42.0\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
I am not able to open IE browser in Windows7 Server 64 bit ,IE 9 Version.
I am able to open all browsers including IE in windows8, IE11 Versions .
I have attached screenshot with error message and code .
I will share my screen over team viewer .
Below is the error log:
Started InternetExplorerDriver server (64-bit)
2.42.0.0
Listening on port 2878
Exception in thread "main" org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. IELaunchURL() returned HRESULT 80070012 ('There are no more files.') for URL 'localhost:2878/'
(WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 21.72 seconds
Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:30'
System info: host: 'ASD-T-MADHUA1', ip: '192.168.0.30', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_05'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:162)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:225)
at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:182)
at org.openqa.selenium.ie.InternetExplorerDriver.(InternetExplorerDriver.java:174)
at org.openqa.selenium.ie.InternetExplorerDriver.(InternetExplorerDriver.java:146)
at UIControls.InternetExplorer.main(InternetExplorer.java:41)

getting an error when opeming IE9 using IntelliJ IDEA IDE for Selenium automation

My code is :
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class Example
{
public static void main(String[] a)
{
WebDriver driver = new InternetExplorerDriver() ;
System.setProperty("sun.net.spi.nameservice.provider.1", "dns,sun");
driver.navigate();
driver.get("http://www.google.com/");
System.out.println("Page title is: " + driver.getTitle());
}
}
Getting an error as:
WARNING: This method of starting the IE driver is deprecated and will be removed in selenium 2.26. Please download the IEDriverServer.exe from http://code.google.com/p/selenium/downloads/list and ensure that it is in your PATH.
Exception in thread "main" org.openqa.selenium.WebDriverException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 289 milliseconds
Build info: version: '2.25.0', revision: '17482', time: '2012-07-18 21:09:54'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_13'
Driver info: driver.version: InternetExplorerDriver
Session ID: 0521cc95-3fbb-43c8-9073-7602d937450b
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:498)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:182)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:167)
at org.openqa.selenium.ie.InternetExplorerDriver.startSession(InternetExplorerDriver.java:133)
at org.openqa.selenium.ie.InternetExplorerDriver.setup(InternetExplorerDriver.java:106)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:52)
at Example.main(Example.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Process finished with exit code 1
I don't know what's wrong.
The warning says what should you do:
WARNING: This method of starting the IE driver is deprecated and will be removed in selenium 2.26. Please download the IEDriverServer.exe from http://code.google.com/p/selenium/downloads/list and ensure that it is in your PATH.
So, first, download the IEDriverServer.exe from http://code.google.com/p/selenium/downloads/list
Correct way to start IE driver is:
System.setProperty("webdriver.ie.driver", "path/to/ IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver() ;
You are using an old version of Selenium and IEDriver.
Download the latest version of Selenium and the IEDriverServer from here:
https://code.google.com/p/selenium/downloads/list

Categories

Resources