Occasionally when G1ANT attempts to open a program (Google Chrome) it gives an error "element not visible", it does not happen often, in fact very rarely.
When it does happen it's at the start of the script on the below line,
the URL is a standard HTTP URL
selenium.open chrome url ♥Url
It seems as though it is not recognizing the program chrome at that moment. The error message is:
element not visible (Session info: chrome=78.0.3904.97)
(Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),
platform=Windows NT 10.0.14393 x86_64)
Do you know what causes this and is there something I can do to stop it happening?
Here's how you can workaround this issue:
♥elementNotVisibleCount = 0
label elementNotVisible
♥elementNotVisibleCount = ♥elementNotVisibleCount + 1
if ⊂♥elementNotVisibleCount>=5⊃
selenium.open chrome url ♥url
end if
selenium.open chrome url ♥url errorjump elementNotVisible if
⊂♥elementNotVisibleCount<4⊃
If an exception occurs, the robot will jump to the elementNotVisible label and try again maximum 4 times before it will try it the last time and if it fails it will finally throw the exception.
Hope, it'll help you.
Related
chromedriver (using WebDriver) has abuilt-in backdoor which informs Javascript webPages taht you are automatically scraping their HTML/JS
I tried to disable that unique character by replacing it within ChromeDriver.exe.
When I do that the scraper breaks. What i changed in Chrome is switching the var key=
'$cdc_asdjflasutopfhvcZLmcfl_' into an equally long string of chars, ints and letters(?). IDK enough about Hexadecimal to say what all this is but this is what some article on Jscript says to do so ChromeDriver doesn't stop when you scrape
driver = webdriver.Chrome(options=options, executable_path=PATH);
{even though I include the path defined and it worked fine a second ago!}
super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
RemoteWebDriver.__init__(
self.start_session(capabilities, browser_profile)
response = self.execute(Command.NEW_SESSION, parameters)
self.error_handler.check_response(response)
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created
from unknown error: Runtime.evaluate threw exception: SyntaxError: Invalid or unexpected token
(Session info: chrome=106.0.5249.61)
Please help! I am scraping a site my company pays for
THat's a tough one. I would suggest reinstalling python and selenium. did you retrieve any rotten virusses?
I am trying to use chrome but I need it to be hidden from the user.
So I tried to use "headless" with ChromeOptions
ChromeOptions options = new ChromeOptions();
options.addExtensions(new File("C://temp//1.14.12_0.crx"));
options.addArguments("disable-infobars");
options.addArguments("headless");
but then I crashed with the following exception:
[1524948093.974][WARNING]: chrome quit unexpectedly, leaving behind temporary directories for debugging:
[1524948093.974][SEVERE]: Port leaked: 12545
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: failed to wait for extension background page to load: chrome-extension://cjpalhdlnbpafiamejdnhcphjbkeiagm/background.html
from unknown error: page could not be found: chrome-extension://cjpalhdlnbpafiamejdnhcphjbkeiagm/background.html
(Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Windows NT 10.0.16299 x86_6
I made some searching and found out that it might be related to the fact that I also load an ad blocker extension, so I temporarily commented the extension loading and the chrome was loaded HIDDEN.
But I still need this extension to work for me when chrome is hidden.
Is there any solution?
Chrome Version - 66
Chrome Driver version - 2.37
Thanks!
So, this one made the trick:
options.addArguments("load-extension=.//resources//1.14.12_0.crx");
instead of
options.addExtensions(new File(".//resources//1.14.12_0.crx"));
Enjoy!
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.)
The full error message is:
Test(s) failed. OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:59662/session timed out after 60 seconds.
----> System.Net.WebException : The operation has timed out
The line in my code where this is happening simply instances a new ChromeDriver instance:
CurrentDriver = new ChromeDriver(section["chromedriverfolder"]);
So my question is... why does a new ChromeDriver invokes the /session URL, and what could be causing it to fail?
I experienced this same error using Selenium.WebDriver.ChromeDriver v2.22 and Chrome v52.0.2743.116 m running on TeamCity 9.x. I was able to fix the problem by rolling back the version of Chrome running on the TeamCity agents to v51.
When examining the agent executing the test, there is a popup with error: "Chrome Automation extension has crashed. Click this balloon to reload the extension."
It seems like a bug with the latest version of Chrome and Selenium.WebDriver.ChromeDriver, but as of yet this is the only lead I've found
EDIT: The link to the ChromeDriver issue
EDIT2: The link to the resolution
I have the answer where ChromeDriver invokes the /session URL, but not to the second part why it is timing out. Please see if it can provide some lead to the debug process to find out the failure :
When we call new ChromeDriver()
It creates RemoteWebDriver in the constructor :
super(new DriverCommandExecutor(service), capabilities);
which ultimately goes to :
public RemoteWebDriver(CommandExecutor executor, Capabilities desiredCapabilities,
Capabilities requiredCapabilities) {
In this method we do startClient which basically does nothing in this particular case
After startClient we do :
startSession(desiredCapabilities, requiredCapabilities);
This method issues the request /session in the following line :
Response response = execute(DriverCommand.NEW_SESSION, parameters);
The DriverCommand.NEW_SESSION is set as newSession which is mapped to post /session in the Command Codec
defineCommand(NEW_SESSION, post("/session"));
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.