/usr/local/bin/chromedriver: cannot execute binary file: Exec format error when tring to use ChromeDriver with Selenium to work on a Raspberry Pi 4? - selenium

I'm stuck trying to get my Selenium script running on my raspberry Pi 4 running with raspbian.
The script is running fine on my mac.
The problem is with setting up the webdriver. I tried installing several webdrivers, including chromedriver, geckodriver, operadriver and phantomjsdriver.
Whenever I'm trying to run the script (which I of course changed to the corresponding drivers) I'm greeted with the following error:
OSError: [Errno 8] Exec format error: 'operadriver'
Also trying to open the driver directly from the shell is resulting in an error:
pi#raspberrypi:/home/shares/users $ chromedriver
bash: /usr/local/bin/chromedriver: cannot execute binary file: Exec format error
My research found some people who got it to work, but all the posts seemed quite old. Some where suggesting the error is pointing to the cpu architecture which is armv7l/armhf in my case.
So is it at all possible to get Selenium running on a pi these days? Has anyone got this to work?

This error message with operadriver...
OSError: [Errno 8] Exec format error: 'operadriver'
and this error message with chromedriver...
ash: /usr/local/bin/chromedriver: cannot execute binary file: Exec format error
...implies that the respective OperaDriver and the ChromeDriver binaries which were invoked was not in proper format.
On your macos system you have used the following WebDriver variants:
GeckoDriver: geckodriver-v0.26.0-macos.tar.gz
ChromeDriver: chromedriver_mac64.tar.gz
where the WebDriver variants matched the underlying os architecture.
Now as you are using armv7 architecture, you have to download and use the relevant format and version of executables downloading it from WebDriver driver for the Chromium Browser
Note: It is to be noted that from geckodriver v0.24.0 onwards:
Removed
Turned off builds for arm7hf, which will no longer be released but can still be built from the source.
References
You can find a couple of relevant discussions in:
OSError: [Errno 8] Exec format error with GeckoDriver and Selenium on MacOS
WebDriverException: Message: Service /usr/lib/chromium-browser/chromedriver unexpectedly exited on Raspberry-Pi with ChromeDriver and Selenium

Related

WebDriverException (Status code 127) when running Selenium + webdriver_manager on gitlab-CI machine (linux)

I'm running a simple CI pipeline on GitLab for a Selenium script headlessly + using webdriver_manager to handle chrome driver binary.
This part is passed:
Get LATEST chromedriver version for None google-chrome
There is no [linux64] chromedriver for browser None in cache
Trying to download new driver from https://chromedriver.storage.googleapis.com/100.0.4896.60/chromedriver_linux64.zip
Driver has been saved in cache [/root/.wdm/drivers/chromedriver/linux64/100.0.4896.60]
But after that I'm getting this error:
WebDriverException: Message: Service /root/.wdm/drivers/chromedriver/linux64/100.0.4896.60/chromedriver unexpectedly exited. Status code was: 127`
What is the problem? Seems like webdriver_manager has a problem by running in CI.
Here is a simple script for reproduce:
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
service = Service(executable_path=ChromeDriverManager().install())
driver = webdriver.Chrome(service=service, options=chrome_options)
driver.get("http://google.com")
driver.find_element('name', 'q').send_keys("Wikipedia")
This is one of the pipelines:
https://gitlab.com/mmonfared/test/-/jobs/2350697126
This is a sample project:
https://gitlab.com/mmonfared/test
I've also opened an issue in webdriver_manager github repo, no answers yet:
https://github.com/SergeyPirogov/webdriver_manager/issues/363
This error message...
WebDriverException: Message: Service /root/.wdm/drivers/chromedriver/linux64/100.0.4896.60/chromedriver unexpectedly exited. Status code was: 127`
...implies that you are executing your tests as the root user.
Deep Dive
As per Chrome doesn't start or crashes immediately
A common cause for Chrome to crash during startup is running Chrome as
root user (administrator) on Linux. While it is possible to work
around this issue by passing --no-sandbox flag when creating your
WebDriver session, such a configuration is unsupported and highly
discouraged. Please configure your environment to run Chrome as a
regular user instead.
Solution
Execute your tests as a non-root user.

ERROR:gl_surface_egl.cc(750)] EGL Driver message (Critical) eglInitialize: No available renderers error using ChromeDriver and Chrome with Selenium

I am trying to execute basic python google chrome automation selenium command
I am getting below error while executing the below code:
from selenium import webdriver
chrome_path=r"xxxx\chromedriver_win32_2\chromedriver.exe"
driver= webdriver.Chrome(chrome_path)
driver.get("<somesite>")
Note:
I have windows7 64 bit OS, Chrome driver version is latest and chome browser as well latest.
ERROR:
DevTools listening on ws://127.0.0.1:12592/devtools/browser/78ac717d-857a-436c-9b28-ee18bc18fa66
[0615/004254.120:ERROR:gl_surface_egl.cc(750)] EGL Driver message (Critical) eglInitialize: No available renderers.
[0615/004254.127:ERROR:gl_surface_egl.cc(1236)] eglInitialize D3D11 failed with error EGL_NOT_INITIALIZED, trying next display type
[0615/004255.175:ERROR:gl_surface_egl.cc(750)] EGL Driver message (Critical) eglInitialize: No available renderers.
[0615/004255.176:ERROR:gl_surface_egl.cc(1236)] eglInitialize D3D9 failed with error EGL_NOT_INITIALIZED
[0615/004255.178:ERROR:gl_initializer_win.cc(196)] GLSurfaceEGL::InitializeOneOff failed.
[0615/004255.184:ERROR:viz_main_impl.cc(152)] Exiting GPU process due to errors during initialization
Code executing....
[0615/005841.064:ERROR:batching_media_log.cc(38)] MediaEvent: {"error":"MediaSource endOfStream before demuxer initialization completes (before HAVE_METADATA) is treated as an error. This may also occur as consequence of other MediaSource errors before HAVE_METADATA."}
[0615/005942.374:ERROR:batching_media_log.cc(38)] MediaEvent: {"
This error message...
[0615/004254.120:ERROR:gl_surface_egl.cc(750)] EGL Driver message (Critical) eglInitialize: No available renderers
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.
This error is generally observed due to mismatch between selenium-chromedriver and google-chrome versions.
Solution
You need to upgrade ChromeDriver and Google Chrome version either to the latest version or to either of the compatible versions as detailed out in the discussion Protractor-selenium error message : “gl_surface_egl.cc eglInitialize D3D9 failed with error EGL_NOT_INITIALIZED”
Outro
You can find a relevant discussion in:
Issue 533043: Hardware Acceleration doesn't work on Chrome anymore. (AMD Xpress 1250)

Unable to read VR Path Registry from C:\Users\Ziaullah\AppData\Local\openvr\openvrpaths.vrpath

I am using Firefox Quantum 59.0 (64-bit), on Windows 7 64 bit,
When I executed my test case in Eclipse Version: Oxygen.2 Release (4.7.2)
with geckodriver.exe version 0.20.0 release date 2018-03-08 both (with 32 bit and 64 bit), then following occurs in Eclipse console
Unable to read VR Path Registry from C:\Users\Ziaullah\AppData\Local\openvr\openvrpaths.vrpath
JavaScript warning: https://my.bepms.com/ExternalLibrary/DateRangePicker-v2.1.17/moment.min.js, line 6: unreachable code after return statement
following is the line which caused the error:
wd.findElement(By.xpath("//p//button[text()='Never Show Again']")).click();
following are the firefox driver settings:
import org.openqa.selenium.firefox.FirefoxDriver;
System.setProperty("webdriver.gecko.driver", "D:\geckodriver.exe");
wd = new FirefoxDriver();
This test successfully executed on
IE Version 11.0.9600.18952 64 bit
Chrome Version 65.0.3325.162 64 bit
quick fix is create empty file C:\Users\Ziaullah\AppData\Local\openvr\openvrpaths.vrpath and then it will not show this exception.

WebDriverError: no such session error using ChromeDriver Chrome through Selenium and Jasmine

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.

SeleniumRC FF3.5.x-3.6 lock file troubles

With Selenium RC 1.0.1, and FF3.5.x or 3.6 I keep seeing this error when trying to run any test,
Failed to start new browser session:
Unable to delete file
\parent.lock
when running the server with either,
java -jar selenium-server.jar -multiwindow
or
java -jar selenium-server.jar
Any one found a way to run a selenium RC test against those version of FF? Here's the full stack trace,
ERROR - Failed to start new browser session, shutdown browser and clear all session data
java.lang.RuntimeException: Firefox refused shutdown while preparing a profile
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.wai
tForFullProfileToBeCreated(FirefoxChromeLauncher.java:311)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.pop
ulateCustomProfileDirectory(FirefoxChromeLauncher.java:106)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.lau
nch(FirefoxChromeLauncher.java:83)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.lau
nchRemoteSession(FirefoxChromeLauncher.java:350)
at org.openqa.selenium.server.browserlaunchers.FirefoxLauncher.launchRem
oteSession(FirefoxLauncher.java:98)
at org.openqa.selenium.server.BrowserSessionFactory.createNewRemoteSessi
on(BrowserSessionFactory.java:357)
at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession
(BrowserSessionFactory.java:122)
at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession
(BrowserSessionFactory.java:84)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.getNewBrowse
rSession(SeleniumDriverResourceHandler.java:699)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.doCommand(Se
leniumDriverResourceHandler.java:393)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handleComman
dRequest(SeleniumDriverResourceHandler.java:364)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handle(Selen
iumDriverResourceHandler.java:125)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
at org.mortbay.http.HttpServer.service(HttpServer.java:909)
at org.mortbay.http.HttpConnection.service(HttpConnection.java:820)
at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:986)
at org.mortbay.http.HttpConnection.handle(HttpConnection.java:837)
at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:
245)
at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Caused by: org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher$Fil
eLockRemainedException: Lock file still present! C:\DOCUME~1\ADMINI~1.SPS\LOCALS
~1\Temp\customProfileDirf09f31ccacf4468385010edaecd5925d\parent.lock
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.wai
tForFileLockToGoAway(FirefoxChromeLauncher.java:269)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.wai
tForFullProfileToBeCreated(FirefoxChromeLauncher.java:309)
... 20 more
INFO - Got result: Failed to start new browser session: Unable to d
elete file C:\DOCUME~1\ADMINI~1.SPS\LOCALS~1\Temp\customProfileDirf09f31ccacf446
8385010edaecd5925d\parent.lock on session null
Restarting the browser, and clearing the cache didn't help. Using FF 3.0.x works just fine.
Seems seleniumRC 1.0.2 just came out today with claimed support for FF3.6 and such. Is working for me.
I was able to fix this issue by following these instructions:
http://jira.openqa.org/browse/SRC-507
This is for an older version of Selenium, but it works just the same. I am having to use 1.0.1 (for IE compatibility) and it has the MaxVersion of FF at 3.5. It was throwing the same error as above.
I changed the various files to '3.6' and it works now.
I just downloaded Selenium RC 1.0.3, and it did NOT fix the problem for me.