org.openqa.selenium.remote.SessionNotFoundException for ChromeDriver - java

I am trying to execute some test cases using chrome driver but out of 4 test cases only 1 is getting executed and for rest of the three i am getting SessionNotFoundException. I searched for the similar question on the portal but all of them are related to Internet Explorer but i am running my test on chrome driver.
Selenium version- 2.42.2
Exception in thread "main" org.openqa.selenium.remote.SessionNotFoundException: no such session
(Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 128 milliseconds
Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:30'
System info: host: 'Admin-PC', ip: '10.0.0.6', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_31'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, chrome= {userDataDir=C:\Users\Admin\AppData\Local\Temp\scoped_dir4568_27180}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, version=41.0.2272.76, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 0fcb3e702dd1c8a23261b902625df216
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.execute(RemoteWebDriver.java:614)
at org.openqa.selenium.remote.RemoteWebDriver.close(RemoteWebDriver.java:463)
at ResumeUpdate.Screen_1_Monster.operation(Screen_1_Monster.java:224)
at ResumeUpdate.Screen_1_Monster.main(Screen_1_Monster.java:341)

I changed some of the xpath and now the program won't throw any exception. I really not able to undertand that if the xpath was wrong then i should have recived NoSuchElementException instead of SessionNotFoundException. I tried to find an answer about why i am getting a wrong exception but till now not able to get a clear answer. Anyone who know about it please share the information

I also faced this problem recently and in my case browser was closing before test can run. e.g.
...........
"Login page" - {
"should have title" in {
pageTitle should be ("Login")
}
close()
}
..........
Replaced with
...........
"Login page" - {
"should have title" in {
pageTitle should be ("Login")
close()
}
}
..........
And fixed the issue.

If the Appium does not receive next command within 60 seconds it shuts down.
[BaseDriver] Shutting down because we waited 60 seconds for a command
[debug] [AndroidDriver] Shutting down Android driver
In my case, my automation was in a loop for more than 60 secs, for the app to finish it's task, which had network dependency.
You can avoid this by adding 'newCommandTimeout' to the capabilities, to increase timeout duration, like so:
capabilities.setCapability("newCommandTimeout", 90); //or seconds
Or you can add try / catch and log more meaningful message.

Related

Selenium WebDriverException: unknown error: call function result missing 'value' using Java

I am getting the below exception when i am trying to run my first test case using selenium webdriver in java. Can someone help me out plssss.....
Starting ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f) on port 48523
Only local connections are allowed.
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Mar 29, 2018 7:34:16 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: call function result missing 'value'
(Session info: chrome=65.0.3325.181)
(Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 6.3.9600 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 31 milliseconds
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'NIL-MKODAGA-D13', ip: '172.16.20.242', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '9.0.1'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome= {chromedriverVersion=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f), userDataDir=C:\Users\mkodagan\AppData\Local\Temp\scoped_dir4652_10811}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=65.0.3325.181, platform=WIN8_1, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]
Session ID: 1a39885769cc96406e2f2732c361c049
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:671)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:272)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:96)
at com.ham.scripts.ClickOnAllLinks.main(ClickOnAllLinks.java:44)
The error says it all :
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: call function result missing 'value'
(Session info: chrome=65.0.3325.181)
(Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 6.3.9600 x86_64)
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'NIL-MKODAGA-D13', ip: '172.16.20.242', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '9.0.1'
Driver info: org.openqa.selenium.chrome.ChromeDriver
The error clearly says that the Selenium Client and ChromeDriver is not getting detected back as in :
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Your main issue is the version compatibility between the binaries you are using as follows :
You are using chromedriver=2.33
Release Notes of chromedriver=2.33 clearly mentions the following :
Supports Chrome v60-62
You are using chrome=65.0
Release Notes of ChromeDriver v2.37 clearly mentions the following :
Supports Chrome v64-66
Your Selenium Client version is 3.4.0 of which is a bit older.
So there is a clear mismatch between the Selenium Client v3.4.0 , ChromeDriver version (v2.33) and the Chrome Browser version (v65.0)
Solution
Upgrade Selenium to current levels Version 3.11.0.
Upgrade ChromeDriver to current ChromeDriver v2.37 level.
Keep Chrome version at Chrome v65.x levels. (as per ChromeDriver v2.37 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Use CCleaner tool to wipe off all the OS chores 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.
As mentioned by #DebanjanB, the problem lies with chromedriver version. From the logs you can see that it uses chromedriver=2.33.506120 which is bit old. Check for the latest version from "https://sites.google.com/a/chromium.org/chromedriver/downloads".
I was also facing the same problem the problem could be solved by updating the chrome driver.
You could uses below approaches for solving it.
Running npm install -g chromedriver
Manually updating the chromedriver, I found the chromedriver being used by the appium resides in below location.
C:\Users\User-Name\AppData\Local\appium-desktop\app-1.5.0\resources\app\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win.
Replace this chromedriver with the latest one and run your code. It should work fine.
Note: The location could be OS specific, so search for chromedriver exact location.

How to write the script for the check box in Selenium web driver by using Java

This is the button that I want to clicked. I want to check this button by writing automation scripts in selenium web driver by using Java.
The following is the code for the button.
<label class="toggle" style="font-size:13px">
<input type="checkbox" name="checkbox-IsEFR" id="checkbox-IsEFR">
<i data-swchon-text="Yes" data-swchoff-text="No"></i>Is Enable for Rules
</label>
Please help me since I am new to automation scripts writing. I wrote the script for check box but it is not working. The following, I have attached the my scripts and the error generated.
#When("^clicks on enable for rules$")
public void clicks_on_enable_for_rules() throws Throwable {
driver.findElement(By.name("checkbox-IsEFR")).click();
}
The error that I received.
org.openqa.selenium.ElementNotVisibleException: Element is not
currently visible and so may not be interacted with Command duration
or timeout: 209 milliseconds Build info: version: '2.53.0',
revision: '35ae25b', time: '2016-03-15 17:00:58' System info: host:
'DELL_I5', ip: '192.168.1.33', os.name: 'Windows 10', os.arch:
'amd64', os.version: '10.0', java.version: '1.8.0_77' Driver info:
org.openqa.selenium.firefox.FirefoxDriver Capabilities
[{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true,
databaseEnabled=true, version=46.0, platform=WINDOWS,
nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true,
locationContextEnabled=true, browserName=firefox,
takesScreenshot=true, javascriptEnabled=true,
cssSelectorsEnabled=true}] Session ID:
03695ef8-bd24-49d6-b8a1-6687e3d0375c 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.RemoteWebElement.execute(RemoteWebElement.java:327)
at
org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:85)
at
mCollector.features.StepDefinitions_mCollector.clicks_on_enable_for_rules(StepDefinitions_mCollector.java:61)
at ✽.And clicks on enable for rules(C:/Users/Admin/workspace/MStudio
- eBilling/src/mCollector/features/mCollector.feature:12) Caused by: org.openqa.selenium.ElementNotVisibleException: Element is not
currently visible and so may not be interacted with Build info:
version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'DELL_I5', ip: '192.168.1.33', os.name: 'Windows
10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_77'
Driver info: driver.version: unknown at .fxdriver.preconditions.visible(file:///C:/Users/Admin/AppData/Local/Temp/anonymous546390466745105063webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:10092)
at .DelayedCommand.prototype.checkPreconditions_(file:///C:/Users/Admin/AppData/Local/Temp/anonymous546390466745105063webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:12644)
at .DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/Admin/AppData/Local/Temp/anonymous546390466745105063webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:12661)
at .DelayedCommand.prototype.executeInternal_(file:///C:/Users/Admin/AppData/Local/Temp/anonymous546390466745105063webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:12666)
at .DelayedCommand.prototype.execute/<(file:///C:/Users/Admin/AppData/Local/Temp/anonymous546390466745105063webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:12608)
You can use explicit wait and ExpectedConditions to wait for the checkbox to be visible
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("checkbox-IsEFR"))).click();
This will wait up to 10 seconds for the element to be visible before clicking on it.
The Error is : "ElementNotVisibleException: Element is not currently visible and so may not be interacted with.."
There may be multiple reason of occurring this error but the strongest possibility is that:
The element is not loaded on the page and your code is trying to click it. To handle this you can put wait statement in your code. A global wait can be imposed by putting implicit wait driver.manage().timeouts().implicitlyWait(5000L, TimeUnit.SECONDS); or you can try putting explicit wait statement before performing the click activity.
Try the solution and I think it'll resolve your issue.
You can search by xpath in Selenium, using something like:
driver.find_element_by_xpath(".//*[contains(text(), 'Is Enable for Rules')]").click()

Selenium standalone 2.45.0; Scripts crash Firefox 38.0.1

I have used 2.44 with an earlier version of Firefox - it was working fine.
FirefoxDriver ffd = new FirefoxDriver();
ffd.get("www.google.com");
Now, even this simple invocation throws an exception:
Exception in thread "main" org.openqa.selenium.WebDriverException: f.QueryInterface is not a function
Command duration or timeout: 190 milliseconds
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'Shivam-PC', ip: '192.168.0.107', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_31'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=38.0.1, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 19f3d00e-ad14-4fc8-9d29-cee47ae44186
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:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:304)
at sele.Sample.main(Sample.java:13)
Caused by: org.openqa.selenium.WebDriverException: f.QueryInterface is not a function
Build info: version: '2.45.0', revision: '5017cb8', time: '2015-02-26 23:59:50'
System info: host: 'Shivam-PC', ip: '192.168.0.107', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_31'
Driver info: driver.version: unknown
at <anonymous class>.FirefoxDriver.prototype.get(file:///C:/Users/Shivam/AppData/Local/Temp/anonymous4862788616202211612webdriver-profile/extensions/fxdriver#googlecode.com/components/driver-component.js:10132)
at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/Shivam/AppData/Local/Temp/anonymous4862788616202211612webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:12274)
at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///C:/Users/Shivam/AppData/Local/Temp/anonymous4862788616202211612webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:12279)
at <anonymous class>.DelayedCommand.prototype.execute/<(file:///C:/Users/Shivam/AppData/Local/Temp/anonymous4862788616202211612webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:12221)
It seems to be common problem from version to version (I faced such kind of problem with FF v.36). Main work around is DO NOT update FF to the newest version (or downgrade if the worst already happened). If your tests work well with particular FF version -> stick with it at least till new version of WebDriver is released.
For myself the most reliable version is FF v.33.
It seems to me that the most robust solution for dealing with Selenium tests on Firefox is to stick with the latest ESR (Extended Support Release) which is mentioned in their CHANGELOG file. The Selenium team has to keep up with the changes introduced in Firefox and that may naturally lead to problems with the most recent versions here and there - not much has changed since the Selenium RC days in this respect.
Update 2016-01-18: There are now two ESR releases mentioned in the CHANGELOG, since with Firefox 33, support for native events has been dropped in favor of synthetic events. The wiki states:
Native events simulate the user interactions better whereas synthetic
events are platform independent, which can be important in Linux when
alternative window managers are used, see native events on Linux.
Native events should be used whenever it is possible.
So depending on your OS, you might try both versions to find the one better suited for you:
For native events: Firefox 31.7.0ESR
For synthetic events: Firefox 38.5.2ESR
Last mention was in Selenium 2.47.0 and included Firefox versions 31, 38 and 39.
If you want to use the latest ESR release no matter what, Mozilla provides a link for that, too.
It is due to your url...change it to http://www.google.com or https://www.google.com
Hope this fixes your problem...Kindly get back if you have any queries

FluentWait ignore not working as expected

I have a Selenium WebDriver test that is failing after dismissing a modal window then waiting for an element. Specifically, it fails looking for an element in a FluentWait call. I've tried various different ways of setting up the wait, but none are working. Here is what I think should work:
The test code that is failing:
driver.findElement(By.className("dismiss")).click(); // this dismisses a modal window
driver.switchTo().defaultContent();
FluentWait<WebDriver> fluentWait = new FluentWait<WebDriver>(driver)
.withTimeout(30, TimeUnit.SECONDS)
.pollingEvery(500, TimeUnit.MILLISECONDS)
.ignoring(NoSuchElementException.class);
fluentWait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.className("next"))));
driver.findElement(By.className("next")).click();
Here the failure happens looking for the element in the wait call:
org.openqa.selenium.NoSuchElementException: Unable to locate element:
{"method":"class name","selector":"next"} Command duration or timeout:
1.33 seconds For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html Build info:
version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:17:32'
System info: host: '7rzrgv1.bsolver.local', ip: '10.0.3.103', os.name:
'Linux', os.arch: 'amd64', os.version: '2.6.32-431.el6.x86_64',
java.version: '1.7.0_60' Session ID:
56c5a752-68fd-4cdb-ae57-2fcefc930f6f Driver info:
org.openqa.selenium.firefox.FirefoxDriver Capabilities
[{platform=LINUX, acceptSslCerts=true, javascriptEnabled=true,
cssSelectorsEnabled=true, databaseEnabled=true, browserName=firefox,
handlesAlerts=true, browserConnectionEnabled=true,
webStorageEnabled=true, nativeEvents=false, rotatable=false,
locationContextEnabled=true, applicationCacheEnabled=true,
takesScreenshot=true, version=24.6.0}]
If I replace the fluentWait.until call with a Thread.sleep(5000), the click() works every time.
An interesting note... this only occurs when running the test on a headless machine running Firefox on top of Xvfb. It doesn't occur when an actual GUI is present.
So, a couple of questions:
Why is FluentWait not ignoring the NoSuchElementException ?
Does anyone have thoughts on a more elegant way to deal with this other than an implicit wait?
I had the same problem. #Karna and #Axl helped me figure it out. I was using import java.util.NoSuchElementException; instead of import org.openqa.selenium.NoSuchElementException;.

get the following error on selenium

I get the following error on selenium,
I don't know how to fix it or what I should do,
unknown error: unhandled inspector error: {"code":-32603,"message":"Cannot navigate to invalid URL"}
(Session info: chrome=29.0.1547.57)
(Driver info: chromedriver=2.2,platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 3 milliseconds
Build info: version: '2.35.0', revision: 'c916b9d', time: '2013-08-12 15:42:01'
System info: os.name: 'Windows Server 2008 R2', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_04'
Session ID: 6c0f76e6f67873a6318edab1d66e4ccf
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={chromedriverVersion=2.2}, rotatable=false, locationContextEnabled=true, version=29.0.1547.57, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, browserConnectionEnabled=false, nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=false, takesScreenshot=true}]
Command duration or timeout: 2.27 seconds
please help
I too got this error "org.openqa.selenium.WebDriverException: unknown error: unhandled inspector error: {"code":-32000,"message":"Cannot navigate to invalid URL"}"
To remove hardcoded URL and calling a URL from a file
I defined like this - ex: url="https://test.com" then I got the above error, after so many research and failures - simply I removed double quotes...it worked
ex: url=https://test.com
It happens if you´re using relative path to open the link. You can use absolute path (starting with http://) or - if it is an internal link/button on the web - you can mapp it as WebElement and perform click() method.
We managed to overcome the above error by changing the initialization Url. but now we are experiencing a bunch of new issues the latest chrome version, latest chromedriver and latest selenium versions.
Everything is extremely slow and we get many timeout since than.

Categories