I was able to run robot framework tests on Google Chrome using RIDE without issue. However just today I tried to run tests that had run properly before and now I'm getting the following error:
Starting test: Bbh-Robot.Test Cases.Search.Search 01 - Basics.Search for Toronto
20161108 13:48:44.163 : INFO : Opening browser 'googlechrome' to base url 'https://www.google.com/'
20161108 13:48:50.591 : FAIL : No browser is open
20161108 13:48:50.592 : WARN : Keyword 'Capture Page Screenshot' could not be run on failure: No browser is open
20161108 13:48:50.596 : FAIL :
WebDriverException: Message: session not created exception
from unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"7332.1","isDefault":true},"id":1,"name":"","origin":"://"}
(Session info: chrome=54.0.2840.87)
(Driver info: chromedriver=2.22.397933 (1cab651507b88dec79b2b2a22d1943c01833cc1b),platform=Windows NT 6.1.7601 SP1 x86_64)
Ending test: Bbh-Robot.Test Cases.Search.Search 01 - Basics.Search for Toronto
I thought it might be an issue with chromedriver so I updated to the most recent version (and made sure the executable was included in my Path variable)
https://chromedriver.storage.googleapis.com/index.html?path=2.25/
But it still thinks I'm using 2.22 for some reason and I'm not sure where to proceed. Is there something I can do with RIDE specifically?
There is nothing you could do with RIDE (other than a clean restart).
This is a problem with PATH setting that somehow is finding first the old version of chromedriver.
(There could be also a running instance of the old chromedriver.)
Related
I am currently facing a problem with Selenium and findElements(By.xpath()).
Currently I am automating on Salesforce (dynamic IDs and we are using text() so we cannot use CSS selectors) and while my XpathFinder (Chrome AddOn) is able to process the Xpath Selenium throws the following error:
invalid selector: Unable to locate an element with the xpath expression
//div[contains(#class,'windowViewMode-normal')]//div[#class='slds-tabs_default' and not(ancestor::*
[contains(#class,'sidebar')])]//force-record-layout-item//(span[not(contains(#class,'assistive')
or #class='slds-checkbox' or contains(#class,'slds-button') or contains(#class,'test-id__field-
value') or contains(#class,'flex-wrap') or contains(#class,'avatar'))]|a|emailui-formatted-email-
wrapper//div[not(*)]|lightning-formatted-text|lightning-formatted-number[text()]|lightning-
formatted-name|lightning-formatted-phone[not(*)]|lightning-formatted-address[not(*)])
because of the following error:
SyntaxError: Failed to execute 'evaluate' on 'Document': The string
'//div[contains(#class,'windowViewMode-normal')]//div[#class='slds-tabs_default' and
not(ancestor::*[contains(#class,'sidebar')])]//force-record-layout-
item//(span[not(contains(#class,'assistive') or #class='slds-checkbox' or contains(#class,'slds-
button') or contains(#class,'test-id__field-value') or contains(#class,'flex-wrap') or
contains(#class,'avatar'))]|a|emailui-formatted-email-wrapper//div[not(*)]|lightning-formatted-
text|lightning-formatted-number[text()]|lightning-formatted-name|lightning-formatted-
phone[not(*)]|lightning-formatted-address[not(*)])'
is not a valid XPath expression.
(Session info: chrome=79.0.3945.117)
(Driver info: chromedriver=2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e),
platform=Windows NT 10.0.17763 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
The problem is in the grouping after
//div[contains(#class,'windowViewMode-normal')]//div[#class='slds-tabs_default' and not(ancestor::*
[contains(#class,'sidebar')])]//force-record-layout-item//...
If i remove the grouping (the ( before the first span and ) at the end of the xpath) and add that part of the xpath after every | the xpath can be evaluated by both XpathFinder and Selenium.
Is my grouping wrong and the browser is just coincidentlly able to evaluate this or is Selenium buggy while evaluating xpaths?
So to summerize it simply:
If i try to evaluate the following
//div//(a|b)
the evaluation failed with the given error. Is the grouping done wrong or am I missing something else?
EDIT:
After getting ChromeDriver to v79 to match the versions the same error appeared:
invalid selector: Unable to locate an element with the xpath expression
(//div[contains(#class,'windowViewMode-normal')]//div[#class='slds-
tabs_default' and not(ancestor::*[contains(#class,'sidebar')])]//force-record-
layout-item)//(span[not(contains(#class,'assistive') or #class='slds-checkbox'
or contains(#class,'slds-button') or contains(#class,'test-id__field-value') or
contains(#class,'flex-wrap') or contains(#class,'avatar'))]|a|emailui-
formatted-email-wrapper//div[not(*)]|lightning-formatted-text|lightning-
formatted-number[text()]|lightning-formatted-name|lightning-formatted-
phone[not(*)]|lightning-formatted-address[not(*)])
because of the following error:
SyntaxError: Failed to execute 'evaluate' on 'Document': The string
'(//div[contains(#class,'windowViewMode-normal')]//div[#class='slds-
tabs_default' and not(ancestor::*[contains(#class,'sidebar')])]//force-record-
layout-item)//(span[not(contains(#class,'assistive') or #class='slds-checkbox'
or contains(#class,'slds-button') or contains(#class,'test-id__field-value') or
contains(#class,'flex-wrap') or contains(#class,'avatar'))]|a|emailui-
formatted-email-wrapper//div[not(*)]|lightning-formatted-text|lightning-
formatted-number[text()]|lightning-formatted-name|lightning-formatted-
phone[not(*)]|lightning-formatted-address[not(*)])' is not a valid XPath
expression.
(Session info: chrome=79.0.3945.117)
This error message...
invalid selector: Unable to locate an element with the xpath expression
//div[contains(#class,'windowViewMode-normal')]...lightning-formatted-address[not(*)])'
is not a valid XPath expression.
(Session info: chrome=79.0.3945.117)
(Driver info: chromedriver=2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e),
platform=Windows NT 10.0.17763 x86_64) (WARNING: The server did not provide any stacktrace information)
...implies that the ChromeDriver was unable to locate an element due to invalid selector.
If you observe the intermediate <span> tag within the xpath you are using, there seems an extra pair of single quotes present which is causing InvalidSelectorException:
//(span[not(contains(#class,'assistive') or #class='slds-checkbox' or contains(#class,'slds-button') or contains(#class,'test-id__field-value') or contains(#class,'flex-wrap') or contains(#class,'avatar'))]
^starting here
Removing this will solve your issue of invalid selector
However your bigger issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.41
Release Notes of chromedriver=2.41 clearly mentions the following :
Supports Chrome v67-69
You are using chrome=79.0
Release Notes of ChromeDriver v79.0 clearly mentions the following :
Supports Chrome version 79
Your Selenium Client version is unknown to us.
So there is a clear mismatch between the ChromeDriver v2.41 and the Chrome Browser v79.0
Solution
Ensure that:
Selenium is upgraded to current levels Version 3.141.59.
ChromeDriver is updated to current ChromeDriver v79.0.3945.36 level.
Chrome is updated to current Chrome Version 79.0 level. (as per ChromeDriver v79.0 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 as non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
I have upgraded to Protractor 6.0.0 and Jasmine 3.3.1, and had to redo all my tests to run asynchronously.
When my Protractor test finishes running, I have an unexplained error at the end. No tests fail, but the process seems to abort irregularly. I am running against Chrome 73 in the latest webdriver, where I had to specifically downgrade to Chrome 73 webdriver because 74 is still in Beta.
Here is a snapshot of a test run:
Test suite 1 Tests
√ should check first thing
√ should check second thing
√ should display another thing
Executed 3 of 94 specs INCOMPLETE (89 SKIPPED).
C:\Users\Joon\AppData\Roaming\npm\node_modules\protractor\node_modules\jasmine-core\lib\jasmine-core\jasmine.js:3190
throw arguments[0];
^
NoSuchSessionError: invalid session id (Driver info:
chromedriver=73.0.3683.68
(47787ec04b6e38e22703e856e101e840b65afe72),platform=Windows NT
10.0.17134 x86_64)
at Object.checkLegacyResponse (C:\Users\Joon\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:585:15)
at parseHttpResponse (C:\Users\Joon\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:533:13)
at Executor.execute (C:\Users\Joon\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:468:26)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
There is no additional error message, the only other SO post I found that had the same error message also had an additional promise rejected error afterwards.
How can I debug / troubleshoot what is causing this error?
I figured it out - there were some calls to browser.wait that did not have an await before them.
One of these was causing a synchronization error which led to that unspecified state management error at the end of the test run.
For anyone else experiencing WebDriver state errors after you upgrade from the control flow to the async flow - be sure to put await calls in front of all Protractor browser interaction calls. The one I had missed was browser.wait but it could be any other call to Protractor that causes this issue
I am building a set of Protractor scripts to evaluate the performance of a web app.
A month ago, the tests were running in both Edge and Chrome. I stepped away from the project for two weeks, and performed a Windows OS update on my return. Since then, when running the test in Microsoft Edge, I get alternating results between 1) an unknown error where the browser never even launches (I will post the cmd output from this result below), and 2) having the Edge browser open but not visiting the base URL it is supposed to (where I am getting a timeout error after being on the Edge homescreen for 10 seconds). I unfortunately did not have the opportunity to run the script before the Windows update, so I am not certain if that is the cause, but I think it is likely. The tests continue to run correctly when operating in Chrome.
I have tried reinstalling Edge's webdriver several times and have chekced its path. I would like to roll back Windows but think this would be a hassle with our IT department, so I am wondering if anyone has found a different solution to this problem?
This is the error when the browser fails to open:
\Browser Tests>protractor edge_conf
[13:32:48] I/launcher - Running 1 instances of WebDriver
[13:32:48] I/hosted - Using the selenium server at http://localhost:17556
[13:32:48] E/launcher - Unknown error
[13:32:48] E/launcher - WebDriverError: Unknown error
at WebDriverError (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:27:5)
at Object.checkLegacyResponse (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\error.js:505:15)
at parseHttpResponse (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\http.js:440:13)
at process._tickCallback (internal/process/next_tick.js:109:7)
From: Task: WebDriver.createSession()
at Function.createSession (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\webdriver.js:777:24)
at createDriver (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\index.js:167:33)
at Builder.build (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\selenium-webdriver\index.js:632:14)
at Hosted.getNewDriver (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\lib\driverProviders\driverProvider.ts:60:29)
at Runner.createBrowser (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\lib\runner.ts:225:39)
at q.then.then (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\lib\runner.ts:391:27)
at _fulfilled (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:834:54)
at self.promiseDispatch.done (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:863:30)
at Promise.promise.promiseDispatch (C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:796:13)
at C:\Users\jarlan\AppData\Roaming\npm\node_modules\protractor\node_modules\q\q.js:556:49
[13:32:48] E/launcher - Process exited with error code 199
I wound up pushing Windows to version 1703 (Build 15063.540), which was easier to get approved than rolling back.
After reinstalling the appropriate WebDriver, everything is working properly with Edge. Still unclear what was causing the problem, but this seems to have worked around it.
I'm the PM for WebDriver at Microsoft. It sounds like you need to get the proper version for your build of Windows.
You can find all the releases of WebDriver here. To see what build of Windows you have just hit [Windows Key] + [R] and type "winver".
I'm trying to make an automated test for my webpage and I'm using Jasmine in tandem with selenium.
When testing on chrome (using chromedriver) I get, unpredictably, the error below. It happens frequently enough that when I run a test suite it hardly ever finishes.
Ive found evidence of this bug but cant find a solid answer: https://bugs.chromium.org/p/chromedriver/issues/detail?id=732 (granted this was for chromium and I'm using chrome)
WebDriverError: no such session
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Mac OS X 10.11.5 x86_64)
at WebDriverError (/Users/XXXXXXX/Documents/sweetmeeting/node_modules/selenium-webdriver/lib/error.js:27:10)
at Object.checkLegacyResponse (/Users/XXXXXXX/Documents/sweetmeeting/node_modules/selenium-webdriver/lib/error.js:639:15)
at parseHttpResponse (/Users/XXXXXXX/Documents/sweetmeeting/node_modules/selenium-webdriver/http/index.js:538:13)
at /Users/XXXXXXX/Documents/sweetmeeting/node_modules/selenium-webdriver/http/index.js:472:11
at ManagedPromise.invokeCallback_ (/Users/XXXXXXX/Documents/sweetmeeting/node_modules/selenium-webdriver/lib/promise.js:1379:14)
at TaskQueue.execute_ (/Users/XXXXXXX/Documents/sweetmeeting/node_modules/selenium-webdriver/lib/promise.js:2913:14)
at TaskQueue.executeNext_ (/Users/XXXXXXX/Documents/sweetmeeting/node_modules/selenium-webdriver/lib/promise.js:2896:21)
at /Users/XXXXXXX/Documents/sweetmeeting/node_modules/selenium-webdriver/lib/promise.js:2820:25
at /Users/XXXXXXX/Documents/sweetmeeting/node_modules/selenium-webdriver/lib/promise.js:639:7
at process._tickCallback (node.js:369:9)
From: Task: WebElement.isDisplayed()
at Driver.schedule (/Users/XXXXXXX/Documents/sweetmeeting/node_modules/selenium-webdriver/lib/webdriver.js:377:17)
at WebElement.schedule_ (/Users/XXXXXXX/Documents/sweetmeeting/node_modules/selenium-webdriver/lib/webdriver.js:1744:25)
at WebElement.isDisplayed (/Users/XXXXXXX/Documents/sweetmeeting/node_modules/selenium-webdriver/lib/webdriver.js:2110:17)
at driver.findElements.then.error (/Users/XXXXXXX/Documents/sweetmeeting/Test/front_end_testing/spec/dashboard_tester.js:251:34)
at ManagedPromise.invokeCallback_ (/Users/XXXXXXX/Documents/sweetmeeting/node_modules/selenium-webdriver/lib/promise.js:1379:14)
at TaskQueue.execute_ (/Users/XXXXXXX/Documents/sweetmeeting/node_modules/selenium-webdriver/lib/promise.js:2913:14)
at TaskQueue.executeNext_ (/Users/XXXXXXX/Documents/sweetmeeting/node_modules/selenium-webdriver/lib/promise.js:2896:21)
at /Users/XXXXXXX/Documents/sweetmeeting/node_modules/selenium-webdriver/lib/promise.js:2775:27
at /Users/XXXXXXX/Documents/sweetmeeting/node_modules/selenium-webdriver/lib/promise.js:639:7
at process._tickCallback (node.js:369:9)
We've also been struggling with this issue for a long time now and recently resolved it so thought I would post here incase it helps someone else.
Turns out for us it was memory related. We run our tests inside a docker container and the docker default dev/shm size is 64mb. Increasing this resolved the "no such session" issue for us.
We use docker compose so just added shm_size: 256M to the docker-compose.yml file.
I recently encountered this exception too. It first appeared to be undeterministic too, but after thorough investigation I realized that it happens deterministrically if you call ChromeDriver.Close() and then tries to FindElement.
In my case, ChromeDriver.Close() was called in an exception handler of a previous test, which happened due to a timing issue. This only affected the next test so it added to the feeling that this issue is flaky. But as I said, my investigation revealed that it is deterministic.
Having said that, this is my experience with that error. Could be that your case is different...
This error message...
WebDriverError: no such session
(Driver info: chromedriver=a.b.c (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Mac OS X 10.11.5 x86_64)
...implies that the ChromeDriver was unable to communicate with the existing Browsing Context i.e. Chrome Browser session.
We have discussed and analyzed this issue within the discussion Issue 732: No such session error - inconsistent problem which appears when running tests for a prolonged period. This error is usually observed after an extended period of executing the Test Suite as follows:
[0127/105308:ERROR:nacl_helper_linux.cc(289)] NaCl helper process running without a sandbox!
Most likely you need to configure your SUID sandbox correctly
[489.849][INFO]: RESPONSE FindElements unknown error: session deleted because of page crash
from tab crashed
(Session info: chrome=p.q.r.s)
[489.849][DEBUG]: Log type 'driver' lost 0 entries on destruction
[489.849][DEBUG]: Log type 'browser' lost 9 entries on destruction
This error is defined in nacl_helper_linux.cc as follows:
// If the Zygote has started handling requests, we should be sandboxed via
// the setuid sandbox.
if (!IsSandboxed()) {
LOG(ERROR) << "NaCl helper process running without a sandbox!\n"
<< "Most likely you need to configure your SUID sandbox "
<< "correctly";
Precisely the FindElement(s) method have FAILED due to sandbox issue and Page Crash occured due to session deletion
Solution
This error can happen due to a lot of diverse reasons and the solution to address this error are as follows:
Initiate the Chrome session configuring ChromeDriver with the argument --disable-impl-side-painting
Additionally, you can also add the argument --enable-gpu-rasterization which allow heuristics to determine when a layer tile should be drawn with the Skia GPU backend. Only valid with GPU accelerated compositing + impl-side painting.
As an option, you can also add the argument --force-gpu-rasterization which always uses the Skia GPU backend for drawing layer tiles. Only valid with GPU accelerated compositing + impl-side painting. Overrides the kEnableGpuRasterization flag.
This error is also observed when the server does not recognize the unique session identifier. This happens if the session has been deleted or if the session ID is invalid in either of the following ways:
Explicit session deletion: A WebDriver session is explicitly deleted when explicitly invoking the quit() method as follows:
from selenium import webdriver
from selenium.common.exceptions import InvalidSessionIdException
driver = webdriver.Chrome(executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
print("Current session is {}".format(driver.session_id))
driver.quit()
try:
driver.get("https://www.google.com/")
except Exception as e:
print(e.message)
#Console Output:
Current session is a9272550-c4e5-450f-883d-553d337eed48
No active session with ID a9272550-c4e5-450f-883d-553d337eed48
Implicit session deletion: A WebDriver session is implicitly deleted when you close the last window or tab invoking close() method as follows:
driver = webdriver.Chrome(executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
print("Current session is {}".format(driver.session_id))
# closes current window/tab
driver.close()
try:
driver.get("https://www.google.com/")
except Exception as e:
print(e.message)
#Console Output:
Current session is a9272550-c4e5-450f-883d-553d337eed48
No active session with ID a9272550-c4e5-450f-883d-553d337eed48
You may also have to add the argument --no-sandbox
Chrome seem to crash often in Docker containers on certain pages due to too small /dev/shm. Similarly, you may have to fix the small /dev/shm size.
An example:
sudo mount -t tmpfs -o rw,nosuid,nodev,noexec,relatime,size=512M tmpfs /dev/shm
It also works if you use -v /dev/shm:/dev/shm option to share host /dev/shm
Another way to make it work would be to add the chrome_options as --disable-dev-shm-usage. This will force Chrome to use the /tmp directory instead. This may slow down the execution though since disk will be used instead of memory.
chrome_options.add_argument('--disable-dev-shm-usage')
Reference
You can find a couple of detailed discussions in:
selenium.common.exceptions.WebDriverException: Message: invalid session id using Selenium with ChromeDriver and Chrome through Python
unknown error: session deleted because of page crash from unknown error: cannot determine loading status from tab crashed with ChromeDriver Selenium
org.openqa.selenium.SessionNotCreatedException: session not created exception from tab crashed error when executing from Jenkins CI server
Sometimes we just expect any problem to be very complex and are looking for its cause far too deep, when a problem could be so obvious.
I was seeing this issue when I explicitly called browser.close() as an exception handler in my logout() method. It terminated the session and all of the following protractor tests were throwing this error.
Once I removed browser.close() and just threw an error instead, the problem was solved.
I have setup protractor-perf tests following the post by Parshuram.
However, when I run the tests using protractor-perf command, I get the following error:
Driver info: driver.version: unknown[0m
Stacktrace:
Error: [execute("(function(){var getTimeMs=(function(){if(window.performance)\nreturn(performance.now||performance.mozNow||performance.msNow||performance.oNow||performance.webkitNow).bind(window.performance);else\nreturn function(){return new Date().getTime();};})();var requestAnimationFrame=(function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(callback){window.setTimeout(callback,1000/60);};})().bind(window);window.__RafRecorder={frames:[],flush:true,record:function(timeStamp){if(__RafRecorder.flush){__RafRecorder.frames=[];__RafRecorder.flush=false;}\n__RafRecorder.frames.push(timeStamp);requestAnimationFrame(__RafRecorder.record);},get:function(){__RafRecorder.flush=true;return __RafRecorder.frames;}};requestAnimationFrame(window.__RafRecorder.record);}());")] Error response status: 13, , UnknownError - An unknown server-side error occurred while processing the command. Selenium error: Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:03'
Info: Tests are run on chrome driver.
Please see if someone can help! Please let me know if more information is required.
PS: If I run the same test with protractor conf.js command, everything works fine. So, seemingly there is some issue with the protractor-perf setup OR I am missing some step somewhere!
The issue is resolved by starting the selenium webdriver. Earlier my tests were using Chromedriver directly and thus the issue.