I was previously using selenium-server-standalone-2.53.1 and chromedriver 2.22 and my acceptance was running perfectly. When I ran it today using this same version it started to fail throwing an Unable to create a new remote session error. Now after upgrading to selenium-server-standalone-3.0.1 and chromedriver-2.25, it's throwing almost the same error. I cant figure out why this is the case. I'm very new to Selenium and would very much appreciate any help.
After upgrade error
Nov 08, 2016 4:27:54 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
Nov 08, 2016 4:27:54 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to original OSS JSON Wire Protocol.
Nov 08, 2016 4:27:54 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to straight W3C remote end connection
org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{browserName=chrome, version=, platform=ANY}], required capabilities = Capabilities [{}]
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
System info: host: 'xxx.yyy.com', ip: '172.19.10.212', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.5', java.version: '1.8.0_60'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:155)
at pet.furiend.website.selenium.test.acceptance.HomePageTest.setUp(HomePageTest.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
-----UPDATE-----
After making a change to the webdriver url, it seems like its starting but I get another error thrown now.
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:251)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:158)
at pet.furiend.website.selenium.test.acceptance.HomePageTest.setUp(HomePageTest.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
It will help a lot if you could let us know what is your Chrome Browser version as it affects significantly ChromeDriver compatibility. For example if you have accidentally updated to version 54 of Chrome Browser then it is likely that you need ChromeDriver 2.25 for it to work properly.
As long as you are saying that it was working with your previous setup; I'll put my money on your actual Chrome Browser (careful not chromeDriver) updating under your nose; hence causing the error. The whole combo:
Selenium Standalone
ChromeDriver
Chrome Browser
is really fragile upon change (personally I force my browsers NOT to update automatically for this reason). If you want to force Chrome Browser not to update at all, just go at the Chrome path and rename update folder to update_old (norm win path: C:\Program Files (x86)\Google\update). This will prohibit Chrome from any further automatic updates.
First of all, if I were you, I'll try the latest ChromeDriver which is v2.25 see if this fixes your issue. You can download from here latest ChromeDriver225
If this didn't fix your issue then try playing around with different versions of Chrome + ChromeDriver until you get it right. Selenium is less susceptible to change and version 3.0.1 should work with any combo for your needs. Have a look here to see which versions of ChromeDriver are compatible with which versions of Chrome Browser.ChromeDriver Downloads/Compatibility
I can confirm that latest Chrome Browser, ChromeDriver and Selenium work well together.
So try this combo here:
Chrome Browser 54.0.2840.87 (latest at the time of writing this post)
Chrome Driver 2.25
Selenium 3.0.1
Best of luck!
Update after op updated to latest version of ChromeDriver
Well as mentioned in my comment below here are my options which work 100% with the latest versions of Chrome (54.0), ChromeDriver (2.25) and Selenium (3.0.1).You can first try to comment all of your capabilities and run chrome with these options instead:
System.setProperty("webdriver.chrome.driver", "C:\\projects\\test\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("test-type");
options.addArguments("--disable-extensions");
So you can activate the above with:
driver = new ChromeDriver(options);
Now regarding capabilities, I think the version one that you are using, does not get or convey a value. If you insist on using it (I find it pointless personally) you can specify a value like following and see if this works for you.
caps.setCapability("browser_version", "54.0.2840.87");
Now, you should have solved it by now, but if something went really really wrong and this actually obstructs you from work, then try this extremely stable combo:
Chrome (48.0.2564.97) from here
Chrome Driver (2.9) from here
Selenium 3.0.1
Hope you can solve it this time, let us know how you get on!
It seems that you are using OSX, is there is any chance that you are launching your tests with the terminal app ?
I was stuck with this error for a while and I managed to fix the issue by unchecking “Set locale environment variables on startup” checkbox in advanced terminal app settings.
Or try to launch your test with this prefix :
LC_NUMERIC=”en_US.UTF-8″ *the command to launch your tests*
I had the same issue on Chrome Browser 55.0.2883.87, Chrome Driver 2.27
Selenium 3.0.1, as author:
"org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session."
Previously Grid was working on Firefox 46.0.1, Selenium 2.52.0.
But I have switched places Node and Hub Url's for:
driver = new RemoteWebDriver(hubAddress.toURL(), capabilities);
and it worked for me.
I hope this will help someone.
Related
I'm running a bunch of test cases every hour using selenium-java 3.12.0; TestNG; Selenoid with docker, Jenkins.
Sometimes (about 1 out of 10 cases) I get the error:
org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: 'autotest.rvkernel.com', ip: '94.130.165.217', os.name: 'Linux', os.arch: 'amd64', os.version: '4.13.0-26-generic', java.version: '1.8.0_181'
Driver info: driver.version: RemoteWebDriver
Capabilities [{mobileEmulationEnabled=false, hasTouchScreen=false, platform=LINUX, acceptSslCerts=false, acceptInsecureCerts=false, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, platformName=LINUX, setWindowRect=true, unexpectedAlertBehaviour=, applicationCacheEnabled=false, rotatable=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.39.562737 (dba483cee6a5f15e2e2d73df16968ab10b38a2bf), userDataDir=/tmp/.org.chromium.Chromium.gURWcu}, takesHeapSnapshot=true, pageLoadStrategy=normal, unhandledPromptBehavior=, databaseEnabled=false, handlesAlerts=true, version=67.0.3396.62, browserConnectionEnabled=false, nativeEvents=true, locationContextEnabled=true, cssSelectorsEnabled=true}]
Session ID: 56c4b100a95d89b3d5702ec8a1a0698a
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:564)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:276)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:83)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement$1.invoke(EventFiringWebDriver.java:376)
at com.sun.proxy.$Proxy14.click(Unknown Source)
at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.click(EventFiringWebDriver.java:389)
at com.Elements.Element.lambda$click$2(Element.java:99)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:208)
at com.Elements.Element.click(Element.java:98)
at com.Elements.Element.click(Element.java:78)
at com.pages.landing.social.MailRuRegisterPage.clickRegister(MailRuRegisterPage.java:37)
at RulVulaknTests.authorization.AuthorizationTest.authorizationUserFromMailRU(AuthorizationTest.java:100)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:571)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:707)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:979)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Cannot decode response content:
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:83)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
... 28 more
Caused by: org.openqa.selenium.json.JsonException: java.io.EOFException: End of input at line 1 column 1 path $
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: 'autotest.rvkernel.com', ip: '94.130.165.217', os.name: 'Linux', os.arch: 'amd64', os.version: '4.13.0-26-generic', java.version: '1.8.0_181'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.json.JsonInput.execute(JsonInput.java:172)
at org.openqa.selenium.json.JsonInput.peek(JsonInput.java:72)
at org.openqa.selenium.json.JsonTypeCoercer.lambda$null$6(JsonTypeCoercer.java:136)
at org.openqa.selenium.json.JsonTypeCoercer.coerce(JsonTypeCoercer.java:122)
at org.openqa.selenium.json.Json.toType(Json.java:62)
at org.openqa.selenium.json.Json.toType(Json.java:52)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
... 31 more
Caused by: java.io.EOFException: End of input at line 1 column 1 path $
at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1401)
at com.google.gson.stream.JsonReader.consumeNonExecutePrefix(JsonReader.java:1576)
at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:534)
at com.google.gson.stream.JsonReader.peek(JsonReader.java:425)
at org.openqa.selenium.json.JsonInput.lambda$peek$0(JsonInput.java:73)
at org.openqa.selenium.json.JsonInput.execute(JsonInput.java:168)
... 37 more
And after this error all remained tests are skipped.
Versions of chrome browser using which I have encountered the error - 66, 67.
This error message...
org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
...implies that the RemoteWebDriver instance was closed abruptly.
Your code trials would have been of some help to debug the issue. Perhaps yout main issue can be one of the following:
You have mentioned that you are using selenium-java 3.12.0 but your error trace logs mentions about selenium-java 3.6.0. So possibly there are multiple instances of selenium-java referenced within this project. So you need to ensure that your project is configured with only one set of selenium-java binaries.
As per best practices:
Upgrade Selenium to current levels Version 3.14.0.
Upgrade ChromeDriver to current ChromeDriver v2.41 level.
Keep Chrome version between Chrome v66-68 levels. (as per ChromeDriver v2.41 release notes)
(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.
As you have mentioned running a bunch of test cases every hour possibly there are multiple dangling instances of ChromeDriver and Chrome which can be viewed through the process list (Linux OS) or TaskManager (Windows OS). You need to always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
If the dangling instances of WebDriver and Web Browser still persists consider killing them with brute force. You can find a detailed discussion in Selenium : How to stop geckodriver process impacting PC memory, without calling driver.quit()?
Incase you program is attempting to set up TCP connections from ports that are greater than 5000 you can refer this article
References
org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Getting "Error communicating with the remote browser. It may have died." with chromedriver
IE11: UnreachableBrowserException: Error communicating with the remote browser. It may have died.
WebDriver fix for UnreachableBrowserException
sorry for the reply to very old questions, but thought it could help someone else.
I was facing the same problem, and earlier I also thoughts issue is with Webdriver but it was not the case,
public static final Target EMAIL = Target.the("email")
.locatedBy(("//input[(#id='login-email-input')]"));
And everything was working fine with,
actor.attemptsTo(Enter.keyValues("someemail#gmail.com")
.into(EMAIL).thenHit(Keys.TAB));
but I thought to clear the input box before enter the new value and replaced above line with,
actor.attemptsTo(Clear.field(EMAIL));
actor.attemptsTo(Enter.keyValues("someemail#gmail.com")
.into(EMAIL).thenHit(Keys.TAB));
And I got the same error. After removing newly added line, things started working correctly.
System.setProperty("webdriver.ie.driver", "D:\Selenium\jars\IEDriverServer\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("http://the-internet.herokuapp.com");
driver.findElement(By.linkText("Forgot Password")).click();
Thread.sleep(3000);
driver.findElement(By.id("email")).sendKeys("testmail#mail.com");
when i run the above code it is working fine with chrome and firefox but when i run using IE it is throwing below error when running 7th step don't understand y it is not working in IE.
Could some one please help me in resolve this issue. Thanks in advance
Nov 20, 2017 2:58:39 PM org.openqa.selenium.remote.ErrorCodes toStatus
INFO: HTTP Status: '404' -> incorrect JSON status mapping for 'no such window' (400 expected)
org.openqa.selenium.NoSuchWindowException: Currently focused window has been closed.
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: 'ML-SIVAKUMARS-P', ip: '192.168.12.159', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{proxy=Proxy(), acceptInsecureCerts=false, browserVersion=11, se:ieOptions={nativeEvents=true, browserAttachTimeout=0, ie.ensureCleanSession=false, elementScrollBehavior=0, enablePersistentHover=true, ie.browserCommandLineSwitches=, ie.forceCreateProcessApi=false, requireWindowFocus=false, initialBrowserUrl=http://localhost:2761/, ignoreZoomSetting=false, ie.fileUploadDialogTimeout=3000, ignoreProtectedModeSettings=false}, timeouts={implicit=0, pageLoad=300000, script=30000}, browserName=internet explorer, pageLoadStrategy=normal, javascriptEnabled=true, platformName=WINDOWS, setWindowRect=true, platform=WINDOWS}]
Session ID: 24a4d291-482e-4399-98fc-f2037c4da5bb
*** Element info: {Using=id, value=email}
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.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:185)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:120)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:586)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:356)
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:402)
at org.openqa.selenium.By$ById.findElement(By.java:218)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:348)
at com.org.learning.tests.TestDayTwo.firstTest(TestDayTwo.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:661)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:744)
at org.testng.TestRunner.run(TestRunner.java:602)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
at org.testng.TestNG.runSuites(TestNG.java:1144)
at org.testng.TestNG.run(TestNG.java:1115)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)
I have been struggling with the same problem since yesterday and finally got my test to work.
Check if you have all the required configurations for the InternetExplorerDriver. For me it was the protected mode settings which I finally tested even though I am on Win 10.
Hope it helps you, too.
There are 2 ways:
Way 1: Setting INITIAL_BROWSER_URL:
File ieFile = new File("D:\\IEDriverServer_x64_2.53.0\\IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", ieFile.getAbsolutePath());
DesiredCapabilities ieCaps = DesiredCapabilities.internetExplorer();
ieCaps.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL, "http://www.bing.com/");
driver = new InternetExplorerDriver(ieCaps);
//some operations on that site
driver.findElement(By.id("sb_form_q")).clear();
driver.findElement(By.id("sb_form_q")).sendKeys("Ripon Al Wasim");
driver.findElement(By.id("sb_form_go")).click();
Way 2: To set a registry entry on the target computer:
For IE 11 only, you will need to set a registry entry on the target computer so that the driver can maintain a connection to the instance of Internet Explorer it creates.
For 32-bit Windows: The key you must examine in the registry editor is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE.
For 64-bit Windows: The key is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE.
Note: Please note that the FEATURE_BFCACHE subkey may or may not be present, and should be created if it is not present. Important: Inside this key, create a DWORD value named iexplore.exe with the value of 0.
For more details you can visit: https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration
Error resolved in my case after enabling protected mode in internet explorer.
Settings--> internet options-->security --> check Enbale protected mode for all the zones.
There are three Settings :
Zoom level set to 100%
Unchecked the Internet Options --> Security--> For Internet and Trusted sites
Unchecked "Enable Protected Mode"
In my case I was getting the error due to missing slash at last of URL "/"
Actual is http://example.com/
but I was passing http://example.com
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: unable to discover open page
Browser is opening but the desired web page is NOT opening & browser is is getting closed within 5secs.
After this the exception is showing up in IDE.
Attached the screenshot of the the browser This is how the browser looks when it opened
Tried uninstalling (deleted user data also)& reinstalling chrome, but din't work :(
Using
JDK 8,
selenium 3.6.0 for Java,
chrome browser-Latest version,
chrome driver-not sure(may be 2.31)
My code
package newPackage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class MyClass {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\ChromeDriver_Selenium\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("http://google.com");
}
}
OUTPUT I am seeing
Starting ChromeDriver (v2.3) on port 20165
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: unable to discover open pages
(Driver info: chromedriver=2.3,platform=Windows NT 6.3 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 20.55 seconds
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T16:15:26.402Z'
System info: host: 'DESKTOP-9KFNBI3', ip: '192.168.0.104', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_144'
Driver info: driver.version: 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:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$24(ProtocolHandshake.java:359)
at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Unknown Source)
at java.util.stream.ReferencePipeline.forEachWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(Unknown Source)
at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
at java.util.stream.FindOps$FindOp.evaluateSequential(Unknown Source)
at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
at java.util.stream.ReferencePipeline.findFirst(Unknown Source)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:362)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:136)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:586)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:217)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:140)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
at newPackage.MyClass.main(MyClass.java:10)
Issue might be due to your chrome driver.Get the chrome driver and set the path in your code and try your code again.Let me know if you are able to overcome this issue.
Use the below link to get latest version of chrome driver(2.33)
From google:
https://sites.google.com/a/chromium.org/chromedriver/downloads
[OR]
From Selenium downloads:
http://www.seleniumhq.org/download/
After some experimentation, I'd agree about ensuring that the chromedriver executable is on your path. You may find that the setting of the system property may be unnecessary.
I don't see any such error in your code.
The error you are observing is because of the Versioning mismatch. You are using Selenium v3.6.0 and chromedriver v2.3 (which is pretty old) and are not compatible.
Solution:
As you are working with the latest version of Selenium i.e. v3.6.0, I would suggest you to use either chromedriver v2.32 or the latest chromedriver v2.33
you are using very old version of ChromeDriver so that it is not compatible with Selenium jars 3.6.0 and browser , use updated ChromeDriver and these issue is resolved.
This issue occurred when your ChromeDriver doesn't support the Browser. Download Latest ChromeDriver from this Link.
or
You can degrade the Chrome browser which is compitable with ChromeDriver 2.31
Update your Chrome Driver to the latest one
I have a basic login test with selenium and testng. When executed from eclipse, it works as expected and invoke Google Chrome. If executed from TESTNG command line, it works fine too.
This is my #Before:
#BeforeMethod
public void setUp() throws Exception {
File file = new File("C:/Selenium-driver/chromedriver.exe");
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
However, if I execute the same test thru Jenkins it says:
Building in workspace C:\EclipsePortable\Data\workspace\GS_TESTNG
[G_TESTNG] $ cmd /c call C:\Windows\TEMP\hudson9049518275115936054.bat
C:\EclipsePortable\Data\workspace\G_TESTNG>_test_login_cmd.bat
C:\EclipsePortable\Data\workspace\G_TESTNG>cd C:\EclipsePortable\Data\workspace\G_TESTNG
C:\EclipsePortable\Data\workspace\G_TESTNG>java -cp C:\EclipsePortable\Data\workspace\G_TESTNG\lib\*;C:\EclipsePortable\Data\workspace\G_TESTNG\bin org.testng.TestNG testng.xml
...
... TestNG 6.9.9 by Cédric Beust (cedric#beust.com)
...
[TestNG] Running:
C:\EclipsePortable\Data\workspace\G_TESTNG\testng.xml
Starting ChromeDriver 2.26.436362 (5476ec6bf7ccbada1734a0cdec7d570bb042aa30) on port 36257
Only local connections are allowed.
FAILED CONFIGURATION: #BeforeMethod setUp
org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.26.436362 (5476ec6bf7ccbada1734a0cdec7d570bb042aa30),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 664 milliseconds
Build info: version: '2.51.0', revision: '1af067d', time: '2016-02-05 19:15:17'
System info: host: 'NMTLA12810', ip: '192.168.0.179', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_102'
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.<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:116)
at com.test.TestA.setUp(TestA.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:510)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:585)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.TestNG.privateMain(TestNG.java:1355)
at org.testng.TestNG.main(TestNG.java:1324)
SKIPPED CONFIGURATION: #AfterClass tearDown
SKIPPED: testGooglePageTitleInChrome
===============================================
TestNG Test Group
Tests run: 1, Failures: 0, Skips: 1
Configuration Failures: 1, Skips: 1
===============================================
===============================================
Main Test Suite
Total tests run: 1, Failures: 0, Skips: 1
Configuration Failures: 1, Skips: 1
===============================================
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter#7fbe847c: 16 ms
[TestNG] Time taken by org.testng.reporters.jq.Main#759ebb3d: 78 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter#ba8a1dc: 59 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter#1c655221: 5 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2#1edf1c96: 16 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 0 ms
Build step 'Exécuter une ligne de commande batch Windows' marked build as failure
Finished: FAILURE
I think you need to install chrome in your instance. for that you follow this basic commands
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
sudo yum install ./google-chrome-stable_current_*.rpm
google-chrome &
It is possible that chrome is installed on your AppData (especially if your are on Windows 7). I am guessing Jenkins could not access the binary from your user directory. Make sure the directory you have Chrome on, is accessible to Jenkins, or try reinstalling chrome again to program files directory.
On the other hand, you can simply instruct Chromedriver where to look for Chrome Binary,
ChromeOptions chromeOptions= new ChromeOptions();
chromeOptions.setBinary("C:\\ThePAthtoChrome.exe");
ChromeDriver driver = new ChromeDriver(chromeOptions);
The problem is these lines in your code:
File file = new File("C:/Selenium-driver/chromedriver.exe");
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
This is a massive anti-pattern that I regularly see. The webdriver.chrome.driver environmental variable was designed so that you could install your chromedriver binaries on multiple systems in different places, and then set the environmental variable on each system so that if a selenium test is ever run on that system it will automatically pick up the location of the binary.
By hard coding this environmental variable via code you are ignoring any preconfigured environmental variable that was set up when the build agent was built, you are not using it in the way it was intended.
If you insist on doing it this way you should always check to see if the env variable is already set before you set it, this way you will not overwrite the existing env variable. You will also need to make sure that the file path you have hard coded exists on your build agent (the secondary cause of your error is that it doesn't) so that if the env variable isn't set, you are actually setting a valid path to the chromedriver binary.
I just check my chrome version (chrome://settings/help(85.0.4183.83 )) and then downloaded chromedriver.exe accordingly (https://chromedriver.chromium.org/downloads)and given new chrome driver.exe path...-This solves my same issue
I had the same problem, I was able to execute selenium scripts through local but when tried executing on Jenkins got error "unknown error: cannot find Chrome binary".
Here is my solution which worked on Jenkins server:
1. Download and enable Xvfb before start of selenium script on jenkins. For more info read here https://wiki.jenkins.io/display/JENKINS/Xvfb+Plugin
2. I am having ubuntu 16.xx os on local and jenkins server.
3. Try to keep chromedriver in "usr/bin" folder only otherwise you may get error.
try {
if(service == null){
service = new ChromeDriverService.Builder()
.usingDriverExecutable(new File("/usr/bin/chromedriver"))// set the chromedriver path
.usingAnyFreePort()
.withEnvironment(ImmutableMap.of("DISPLAY", ":15"))
.withSilent(true)
.build();
service.start();
}
System.out.println("Reading chrome driver");
System.setProperty("webdriver.chrome.driver","/usr/bin/chromedriver");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--headless");
WebDriver driver = new ChromeDriver(chromeOptions);
driver.get("https://google.com");
driver.quit();
}
catch(Exception ex){
System.out.println(ex.getMessage());
}
This code i tried it solved my one week unresolved problem,
Thanks to Aastha Chopra..
ChromeOptions chromeOptions= new ChromeOptions();
chromeOptions.setBinary("C:\\Program Files (x86)\\Google\\Chrome Beta\\Application\\chrome.exe");
System.setProperty("webdriver.chrome.driver","C:\\STUDY\\Selenium\\CHROMEDRIVERS\\chromedriver.exe");
ChromeDriver driver = new ChromeDriver(chromeOptions);
driver.get("http://newtours.demoaut.com/");
Mac users, Please make sure that chromeBinary file is placed at bin folder and chrome if it is in downloads move it to application.
Check the OS of the Agent Node.
Check how Jenkins Access the agent Node.
if its via JNLP and the OS is below Window 7, through Admin right install the Chrome in C:/Program Files(x86) where Jenkins can access the chrome.exe and set binaries using below code:
ChromeOptions options = new ChromeOptions();
if(System.getProperty("os.name").equals("Windows Server 2012 R2")){
File ChromeExePath =new File("C:/Program Files (x86)/Google/Chrome/Application/chrome.exe");
if (ChromeExePath.exists()){
options.setBinary(ChromeExePath);
}
}
ChromeDriver driver = new ChromeDriver(options);
I was having similar issue in JS, it got fixed after installing npm i chromedriver
Please check your binary path if still not works then
you should have installed chrome in your machine
and your chromedriver.exe version should accordingly (like if you have chrome 87.0 ver then download chromedriver.exe for ver 87.0)
download form it from
https://chromedriver.chromium.org/downloads
and given new chromedriver.exe path to your script.
This works fine for me
ChromeOptions options = new ChromeOptions();
options.BinaryLocation="C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe";
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.SetCapability(ChromeOptions.Capability, options);
ChromeDriver driver = new ChromeDriver("C:\\test3", options);
This worked for me in C#. my chromedriver.exe is in test3 folder. Also my issue was that version of chrome was not same of chromedriver. This will definitely work:)
ChromeOptions chromeOptions= new ChromeOptions();
chromeOptions.setBinary("C:\\Program Files (x86)\\Google\\Chrome Beta\\Application\\chrome.exe");
System.setProperty("webdriver.chrome.driver","C:\\STUDY\\Selenium\\CHROMEDRIVERS\\chromedriver.exe");
ChromeDriver driver = new ChromeDriver(chromeOptions);
driver.get("http://newtours.demoaut.com/");
It worked for me. I have coded as below
ChromeOptions chromeOptions= new ChromeOptions();
chromeOptions.setBinary("C:\\Users\\kannanu\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe");
System.setProperty("webdriver.chrome.driver",ChromeExePath);
ChromeDriver driver = new ChromeDriver(chromeOptions);
driver.get("http://newtours.demoaut.com/");
I ran the following command to install chromedriver and it worked:
brew cask install chromedriver
I'm trying to run some Selenium tests using the ChromeDriver, and I started getting this error:
Starting ChromeDriver 2.23.409699 (49b0fa931cda1caad0ae15b7d1b68004acd05129) on port 42985
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":"7576.1","isDefault":true},"id":1,"name":"","origin":"://"}
(Session info: chrome=54.0.2840.59)
(Driver info: chromedriver=2.23.409699 (49b0fa931cda1caad0ae15b7d1b68004acd05129),platform=Windows NT 10.0.14393 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.48 seconds
Build info: version: 'unknown', revision: '2aa21c1', time: '2016-08-02 14:59:43 -0700'
System info: host: 'SUJITH', ip: '192.168.43.228', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_101'
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:683)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:247)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:143)
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:116)
at Selenium.Test2.main(Test2.java:15)
Why is this happening, and how can I fix it?
Update your chromedriver with lastest version. And please clarify your question.
https://chromedriver.storage.googleapis.com/index.html?path=2.24/
If your chrome browser is recently updated to V54.0.x, then you might get this error. The solution for this problem is simply to update your chrome driver.
Choose chrome driver from the below link that will suit your system architecture.
Latest Chromedriver v2.25
This issue started showing up after chrome Version 54.0.x updates.
Remove the older chromedriver from your path and update your chromedriver to 2.24. This should resolve your issue.
I had the same issue . Updating the chrome driver solved my problem.
A few things to bare in mind for these type of cases:
Disable browsers auto update - at least on your slaves to avoid these type of breaking your CI process. Link for how to on Chrome, and be sure to watch these settings on the installation.
Versioning is the first thing to check with Selenium when it breaks all of a sudden. See notes for version compatibility.
I'm using my own Maven plugin to check compatibility between chromedriver and Chrome version
Hope it helps...
You might be using the lower version of the chrome driver.
org.openqa.selenium.SessionNotCreatedException: session not created exception
I had the similar issue and was getting the exception as above. So always check the latest version of driver from here: https://sites.google.com/a/chromium.org/chromedriver/downloads
You might need to set in /etc/hosts
127.0.0.1 localhost
In my case the problem was that I kept a Selenium script running for too much time than I run out of disk free space.
So, I just clean out the Temp folder and created a routine to keep cleaning selenium folders, and problem solved.
You will get this error when your code looks like below:
WebDriver driver = new ChromeDriver();
System.setProperty("webdriver.chrome.driver", "C:\\driver\\chromedriver.exe");
You have to setProperty first and then create driver instance next
System.setProperty("webdriver.chrome.driver", "C:\\driver\\chromedriver.exe");
WebDriver driver = new ChromeDriver();