Selenium::WebDriver::Error Chrome Crashed on M1 chip - selenium

I've spent several days trying to solve this issue I'm encountering with the following code:
caps = Selenium::WebDriver::Remote::Capabilities.chrome(
"chromeOptions" => {
:args => ['--user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36 LegalMonsterNoBlock"']
}
)
driver = Selenium::WebDriver.for :remote, url: selenium_host, :desired_capabilities => caps
driver.get(url)
I'm trying to run a test that calls this method. The test runs fine. It opens up Chrome runs the test, but whenever I reach the part of my application that calls the above method, the test fails with the following error:
Minitest::UnexpectedError: Selenium::WebDriver::Error::UnknownError: unknown error: Chrome failed to start: crashed
(chrome not reachable)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: '7a6aaccda364', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.19.121-linuxkit', java.version: '1.8.0_232'
Driver info: driver.version: unknown
remote stacktrace: #0 0x0040004b6479 <unknown>
My setup:
Macbook with Apple M1, running Big Sur 11.2.2
ruby version 2.7.2
ChromeDriver 89.0.4389.23 (for m1 chip)
Chrome version 89.0.4389.72 (Official Build) (arm64)
gem selenium-webdriver version 3.142.3
Running a docker selenium/standalone-chrome-debug:3.141.59-zinc
I have tried several things already:
Adding --headless, --no-sandbox options to args: args => ['--headless', '--no-sandbox' ...
Installing chromedriver and chrome via brew instead of downloading binary
Reinstalling chrome and chromedriver
Explicitly speficying path to both chrome and chromedriver (Selenium::WebDriver::Chrome.path = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome' and Selenium::WebDriver::Chrome.driver_path="/path/to/chrome_driver_binary/chromedriver")
Any other experiencing such issues?

It turned out that it is my docker image, that does not support the arm64-architecture, so it was this step:
Running a docker selenium/standalone-chrome-debug:3.141.59-zinc.
There was no issue if I disabled the part of the tests that used the docker container. I imagine this is no possible for everyone, but lets hope that there'll be a selenium image that will support arm64 architecture soon.
See Selenium issue here.

For me using a docker image compatible with the arm64 architecture solved the issue. It was easy to set it up after understanding the problem using an image from https://hub.docker.com/u/seleniarm
I just run the command
docker run -d -p 4444:4444 seleniarm/standalone-chromium
This set it up where I needed and worked just fine.
I had the same error when I was trying to run in a docker using the below command.
docker run -d -p 4444:4444 selenium/standalone-chrome
My solution was mentioned in the github answer for the issue posted above and the link to the answer so we can give the proper credits is this:
https://github.com/SeleniumHQ/docker-selenium/issues/1076#issuecomment-788343926
Hope this sheds some light for others.

Related

Laravel + sail + dusk => Error: Could not start a new session [...] Chrome failed to start

I just can't get Laravel dusk running. I've searched the internet and tried almost everything. I hope anyone knows the trick.
To rule out any self introduced problems I stated with a brand new Laravel project: curl -s "https://laravel.build/example-app" | bash. I'm using a Macbook Air (M1 chip) and therefore I have to change the docker-compose.yml and add platform=linux/amd64 to the containers. Thereafter ran ./vendor/bin/sail build and started up the containers. Next installed Dusk: ./vendor/bin/sail composer require --dev laravel/dusk and ran the install command (./vendor/bin/sail artisan dusk:install) as by the documentation.
At this point no additional modifications in any file have been made. Laravel Dusk ships with the default browser test. (tests/Browser/ExampleTest.php) When I run the command ./vendor/bin/sail dusk the following error will show:
1) Tests\Browser\ExampleTest::testBasicExample
Facebook\WebDriver\Exception\SessionNotCreatedException: Could not start a new session. Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed.
(chrome not reachable)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Build info: version: '4.1.1', revision: 'e8fcc2cecf'
System info: host: '64671e354051', ip: '192.168.32.3', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.76-linuxkit', java.version: '11.0.13'
Driver info: driver.version: unknown
Build info: version: '4.1.1', revision: 'e8fcc2cecf'
System info: host: '64671e354051', ip: '192.168.32.3', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.76-linuxkit', java.version: '11.0.13'
Driver info: driver.version: unknown
/var/www/html/vendor/php-webdriver/webdriver/lib/Exception/WebDriverException.php:125
/var/www/html/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:372
/var/www/html/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:131
/var/www/html/tests/DuskTestCase.php:46
/var/www/html/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:219
/var/www/html/vendor/laravel/framework/src/Illuminate/Support/helpers.php:243
/var/www/html/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:220
/var/www/html/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:98
/var/www/html/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:66
/var/www/html/tests/Browser/ExampleTest.php:21
What I tried
The files in ./vendor/laravel/dusk/bin/ have the right permissions.
./vendor/bin/sail artisan dusk:chrome-driver --all => ChromeDriver binary successfully installed for version 100.0.4896.60. . But the same dusk error will show.
Tried to run the ChromeDriver directly: ./vendor/bin/sail bash => ./vendor/laravel/dusk/bin/chromedriver-linux. This results in an error:
./vendor/laravel/dusk/bin/chromedriver-linux: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
I Found an other StackOverflow post to fix this issue by installing the following packages via the sail root-shell: apt update; apt install libnss3-dev libgdk-pixbuf2.0-dev libgtk-3-dev libxss-dev;. Now the chromedriver-linux is starting without errors. Dusk still fails with the same error.
Has anyone a clue?
I was getting the same error when running sail artisan dusk.
When started using sail dusk instead everything worked.

wdio - ERROR: Unable to create new service: ChromeDriverService

When I try to run tests with wdio I am getting ERROR: Unable to create new service: ChromeDriverService It also says Driver info: driver.version: unknown
In my wdio.conf.js file, I have
seleniumArgs: {
version: '3.141.0',
drivers: {
chrome: {
version: '2.43'
},
firefox: {
version: '0.23.0'
}
}
},
seleniumInstallArgs: {
version: '3.141.0',
drivers: {
chrome: {
version: '2.43'
},
firefox: {
version: '0.23.0'
}
}
},
Any idea what I am doing wrong here, or what other information I could provide? The full error is:
ERROR: Unable to create new service: ChromeDriverService
Build info: version: '3.141.0', revision: '2ecb7d9a', time: '2018-10-31T20:22:52'
System info: host: '<me>', ip: '<my_ip>', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.6', java.version: '1.8.0_212'
Driver info: driver.version: unknown
I don't know if this will help anyone, but the way I fixed this was to do locate selenium on my machine and just delete everything. I wonder if global selenium was messed up or something? After I did npm install in my repository again, the tests were able to run with ChromeDriverService.
This error message...
ERROR: Unable to create new service: ChromeDriverService
Build info: version: '3.141.0', revision: '2ecb7d9a', time: '2018-10-31T20:22:52'
System info: host: '<me>', ip: '<my_ip>', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.6', java.version: '1.8.0_212'
Driver info: driver.version: unknown
...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are trying to use chrome=2.43 which is an invalid version.
Your chromedriver version is unknown to us.
Release Notes of chromedriver=77.0 clearly mentions the following :
Your Selenium Client version is 3.141.0 of 2018-10-31T20:22:52 which is almost a year older.
Your JDK version is 1.8.0_111 which is pretty ancient.
So there is a clear mismatch between the Selenium Client v3.141.0 , ChromeDriver and the Chrome Browser
Solution
Ensure that:
Selenium is upgraded to current levels Version 3.141.59.
ChromeDriver is updated to current ChromeDriver v77.0 level.
Chrome is updated to current Chrome Version 77.0 level. (as per ChromeDriver v77.0 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
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.

How to set chromeDriver location in Protractor project

In my Protractor project I get below error when execute npm test command
21:55:20] E/runner - Unable to start a WebDriver session.
[21:55:20] E/launcher - Error: SessionNotCreatedError: Unable to create new service: ChromeDriverService
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: '00000FJ26VN2', ip: '172.30.161.17', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: driver.version: unknown
I tried below solution and didn't work for me.
Solution 1
This couldn't do due to my machine restriction
Other question I have is even after replacing the correct chromedriver in the below location when I start the server it still shows the wrong one. (i.e. chromedriver_75.0.3770.8.exe, But I replace that with chromedriver_74.0.3729.6.exe which is my current browser version.
File Location: protractor-cucumber-typescript\node_modules\protractor\node_modules\webdriver-manager\selenium
logs when start the server
λ npm run webdriver-start
> protractor-typescript-cucumber#4.0.0 webdriver-start c:\Repository\GitExt\Protractor\protractor-cucumber-typescript
> webdriver-manager start
[22:08:04] I/start - java -Dwebdriver.chrome.driver=c:\Repository\GitExt\Protractor\protractor-cucumber-typescript\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_75.0.3770.8.exe -Dwebdriver.gecko.driver=c:\Repository\GitExt\Protractor\protractor-cucumber-typescript\node_modules\protractor\node_modules\webdriver-manager\selenium\geckodriver-v0.24.0.exe -jar c:\Repository\GitExt\Protractor\protractor-cucumber-typescript\node_modules\protractor\node_modules\webdriver-manager\selenium\selenium-server-standalone-3.141.59.jar -port 4444
[22:08:04] I/start - seleniumProcess.pid: 1380
22:08:04.708 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
22:08:04.825 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444
2019-06-13 22:08:04.883:INFO::main: Logging initialized #446ms to org.seleniumhq.jetty9.util.log.StdErrLog
22:08:05.145 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
22:08:08.881 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
So as a resolution Can I pointing to the chromedriver specifically? What is the relationship between selenium-server-standalone-3.141.59.jar and the chromedriver? Is there a way to find the compatible chromedriver version for this jar
In my case I don't have access to update or downgrade my machine chrome browser version. So how it's possible to change the web driver version to align with chrome browser version.
I figured out the issue here and managed to have resolution.
Problem : Even though I placed the matching chromedriver.exe in path (c:\Repository\GitExt\Protractor\protractor-cucumber-typescript\node_modules\protractor\node_modules\webdriver-manager\selenium) it's still looking for the original version which is coming fromwebdriver-update command.
So what I did was
Removed chromedriver from the above path.
Add the preferred one in some folder location and set that in env. variables. So if the driver is missing in the project folder it always goes to set path in the env. variables which the right one.
Despite of above solution I just wondering how I can change the driver version when run webdriver-update command?

How to install mobile application(Android/iOS) in emulators directly by accessing path from different network location using appium?

I'm launching my android & ios emulators in windows & mac machine respectively,
My application is generated by CI system in a network location (path: \xxx.yyy.com\\Mobile\android and \xxx.yyy.com\\Mobile\ios)
If try to install the mobile app in emulators by directly accessing the path(path:\xxx.yyy.com\\Mobile\android), getting below error. How to handle this situation?
Error in console :
Exception encountered in getDriver Method: An unknown server-side error occurred while processing the command. Original error: Error: UNKNOWN: unknown error, lstat '\xxx.yyy.com\\Mobile\android\android_application.apk' (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 23.25 seconds
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'MOBILETESTTR01', ip: '10.7.0.86', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_121'
Driver info: io.appium.java_client.android.AndroidDriver
Environment:
Appium version that exhibits the issue: 1.8.0
Desktop OS/version used to run Appium: Windows 10
Real device or emulator/simulator:simulator
Selenium server: 2.53.1
java-client: 4.0.0
is there any way to install the mobile app by directly accessing the path using appium ? Please suggest .
Thanks in Advance!
You can checkin apk file as a part of you project in git and then use following capability,appium will auto install the apk.
caps.setCapability("app","/src/test/resources/your.apk");
caps.setCapability("appPackage","com.app.package");
caps.setCapability("appActivity",".Launchable-Activity");

org.openqa.selenium.SessionNotCreatedException because of "Chrome version must be >= 64.0.3282.0" although version is 65.0.3325.181 on Travis CI

While I was attempting to extend Arquillian PrimeFaces's .travis.yml with a setup for phantomjs and chromeheadless browser driver for functional tests with Selenium, I experienced
java.lang.RuntimeException: Could not create statement
Caused by: java.lang.RuntimeException:
Unable to instantiate Drone via org.openqa.selenium.chrome.ChromeDriver(Capabilities): org.openqa.selenium.SessionNotCreatedException: session not created exception: Chrome version must be >= 64.0.3282.0
(Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Linux 4.4.0-101-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 564 milliseconds
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
System info: host: 'travis-job-bdbf5b81-b2fa-4377-b5de-da7743f04986', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-101-generic', java.version: '1.8.0_151'
Driver info: driver.version: ChromeDriver
Caused by: org.openqa.selenium.SessionNotCreatedException:
session not created exception: Chrome version must be >= 64.0.3282.0
(Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Linux 4.4.0-101-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 564 milliseconds
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
System info: host: 'travis-job-bdbf5b81-b2fa-4377-b5de-da7743f04986', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-101-generic', java.version: '1.8.0_151'
Driver info: driver.version: ChromeDriver
So, I updated chromium-browser with sudo add-apt-repository --yes ppa:saiarcot895/chromium-dev && sudo apt-get update && sudo apt-get install --yes chromium-browser and verified that it's the only Chrome binary and has a matching version with which -a chromium-browser && chromium-browser --version which reveals that the only binary is /usr/bin/chrominum-browser and has version 65.0.3325.181. However, the error persists.
I researched and found issues with Chrome on Travis CI like
https://github.com/travis-ci/travis-ci/issues/938 which is about permissions (as opposed to versions)
Chromedriver on Travis-CI which summarizes issues
and checked the Arquillian web driver configuration options for Chrome which don't seem to include one to expose the actual pick up of the ghost 64.x binary.
An example run of the failure can be found at https://travis-ci.org/krichter722/arquillian-primefaces/jobs/364342730.
In your question you have mentioned about using Chrome v65.0.3325.181 but the error stack strace shows different versions as follows :
Caused by: org.openqa.selenium.SessionNotCreatedException:
session not created exception: Chrome version must be >= 64.0.3282.0
This essentially means ChromeDriver is unable to detect the right version of chrome binary. It appears you either have installed multiple instances of Chrome Browsers and have multiple instances of chrome binaries within your system or there are multiple stray instances of chrome binaries available within your system.
Solution
You must ensure that Chrome is installed at the optimum location as the server expects you to have Chrome installed in the default location for each system as per the snapshot below :
Note : For Linux systems, the ChromeDriver expects /usr/bin/google-chrome to be a symlink to the actual Chrome binary. You can also override the Chrome binary location following the documentation Using a Chrome executable in a non-standard location.
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.