Cannot find chrome driver on Jenkins server - google-chrome

The issue that I am running into is that I cannot find the chrome driver on my Jenkins server. I am trying to run my selenium tests using the chrome driver.
Here is what I have tried so far:
1. Checked the version of Google Chrome that is installed
2. Commands that I have tried so far
which google-chrome
google-chrome --version
google-chrome --headless --disable-gpu --screenshot --window-size=1280,1696
Here is the error that I am receiving:
java.lang.IllegalStateException: The driver executable does not exist:

Related

How can I get chromedriver to work properly with chrome in wsl2?

I am trying to run automated tests on a repository forked from here. I haven't really worked with yarn or mocha before (or chromedriver) so I'm going off of what the instructions are saying.
I've set up Ubuntu 18.04 in wsl2 and installed google-chrome-stable and chromedriver both at version 99.0.4844.51 in /usr/bin/. I have yarn start running in one terminal and when I try actually run yarn test it gives me:
SessionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version 94
Current browser version is 99.0.4844.51 with binary path /usr/bin/google-chrome-stable
I've tried upgrading chromedriver from here to version 100.0.4896.20 but it gives me the same error saying it only supports Chrome version 94. I'm having a hard time trying to find Google version 94 for linux, and I'll be happy either way, either upgrading the chromedriver or downgrading chrome.

TestCafe Update "local" Chrome in Jenkins

I am running tests in Jenkins and the tests are running on outdated Chrome 71 and I want to update the chrome it is using. I've tried updating my package.json to current TestCafe but it is still running 71. when I run node_modules/.bin/testcafe --version it just lists firefox, chrome. It seems that since the chrome is in node_modules I should be able to update to latest but I haven't found anything online to show how to do so.
Running locally on my machine chrome is v91. I thought doing an 'npm i' locally and pushing that branch would update but it was not successful.
Jenkins output:
npm i
node_modules/.bin/testcafe --version
1.15.0
node_modules/.bin/testcafe -e chrome:headless auth-subscriber-signs-in-validates-homepage.js
Running tests in: Chrome 71.0.3578.98 / Linux 0.0
TestCafe doesn't upgrade or downgrade browsers. It just searches the installed browsers and runs tests in them. You need to inspect the Jenkins job and found the way how browsers are installed for it.

Running "google-chrome" on WSL Ubuntu as --headless --no sandbox gives multiple errors - how do I take screenshot using headless in WSL?

I'm running Windows 10 and I have been using an Ubuntu Linux distro under the Windows Linux Subsystem.
I want to be able to use Chrome.exe or google-chrome to run headless and take screenshots, generate pdfs etc... as part of library calls, but can't see to do that (e.g. to use jupyter_to_medium library launches chrome in the background to take screenshot).
I have tried multiple things to debug it with google-chrome independently of the library or programme I'm using.
Here's what I've tried:
I can launch Chrome (Windows executable) via the Ubuntu terminal, having redirected it to the Windows executable:
/mnt/c/Program\ Files\ \(x86\)/Google/Chrome/Application/chrome.exe
When I do that, a new tab opens in my Windows Chrome browser so no issues here.
When I try to use google-chrome headless in ubuntu terminal I get MULTIPLE ISSUES e.g.
2a) Trying to get a screenshot - FAILs showing Network service crashed, restarting service endless loop - had to CTRL^C to stop it
(base) etzimopoulos#DESKTOP-HI9P6E4:~$ google-chrome --headless --disable-gpu --screenshot https://www.chromestatus.com/
[0626/055458.471044:ERROR:udev_watcher.cc(61)] Failed to enable receiving udev events.
[0626/055458.612113:ERROR:network_service_instance_impl.cc(262)] Network service crashed, restarting service.
[0626/055458.696014:ERROR:network_service_instance_impl.cc(262)] Network service crashed, restarting service.
...
2b) Trying to get a screenshot using a different parameters --no-sandbox --disable-setuid-sandbox , getting different error this time.
$ sudo google-chrome --no-sandbox --disable-setuid-sandbox --headless --screenshot https://www.chromestatus.com/
[0626/061854.348849:ERROR:udev_watcher.cc(61)] Failed to enable receiving udev events.
[0626/061855.311675:ERROR:platform_shared_memory_region_posix.cc(46)] Descriptor access mode (0) differs from expected (2)
[0626/061855.312483:WARNING:crash_handler_host_linux.cc(366)] Could not translate tid - assuming crashing thread is thread group leader; syscall_supported=0
[0626/061855.474617:WARNING:crash_handler_host_linux.cc(366)] Could not translate tid - assuming crashing thread is thread group leader; syscall_supported=0
--2020-06-26 06:18:55-- https://clients2.google.com/cr/report
Resolving clients2.google.com (clients2.google.com)... 216.58.210.46, 2a00:1450:4009:800::200e
Connecting to clients2.google.com (clients2.google.com)|216.58.210.46|:443... connected.
HTTP request sent, awaiting response... [0626/061855.655013:ERROR:headless_shell.cc(399)] Abnormal renderer termination.
429 Too Many Requests
2020-06-26 06:18:55 ERROR 429: Too Many Requests.
Unexpected crash report id length
Failed to get crash dump id.
Report Id: ```
Trying to run the Windows executable Chrome.exe with same parameters, seems to run but not screenshot is being taken (no new files in my directory)
Trying to run google-chrome without elevated privilages in WSL I get a different error:
google-chrome --headless --disable-gpu --screenshot https://www.chromestatus.com/ Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Permission denied Failed to generate minidump.Illegal instruction (core dumped)
Any help or direction would be hugely appreciated. My other option would be to run a VM on windows 10 with native Linux UI and terminal, which would probably work.
But is there a way to have it all setup in WSL?
Thank you.
Try this (tested in wsl2)
In your wsl2 ubuntu console enter the following commands:
#install packages
sudo apt-get install -y curl unzip xvfb libxi6 libgconf-2-4 fonts-liberation
#get latest chrome
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
#install it
sudo apt install ./google-chrome-stable_current_amd64.deb
#test a screenshot
google-chrome --headless --disable-gpu --screenshot https://www.chromestatus.com/

Headless chrome print to pdf hangs on certain sites when running on debian

I am trying to use Headless chrome to print to pdf on debian 9.
On some sites it hangs and never returns with an error.
When trying to do the same on Windows 10 it works.
Example site: https://www.ynet.co.il/home/0,7340,L-8,00.html
Turning on logging does not reveal any relevant information.
I am assuming it has something to do with fonts but since it hangs and return no error i am not sure how to proceed.
Is there some to understand why it hangs?
Setup on debian:
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
dpkg -i google-chrome-stable_current_amd64.deb; apt-get -fy install
Creating pdf on debian:
/usr/bin/google-chrome --headless --no-sandbox --disable-gpu --displayHeaderFooter=false --print-to-pdf=result.pdf https://www.ynet.co.il/home/0,7340,L-8,00.html
Creating pdf on windows (need to install google chrome and change the path to it accordingly):
"c:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --headless --no-sandbox --disable-gpu --displayHeaderFooter=false --print-to-pdf=result.pdf https://www.ynet.co.il/home/0,7340,L-8,00.html

Unable to run headless chrome inside vagrant

I am trying to run unit tests in headless chrome(version 61).
I have mentioned the browsers as 'ChromeHeadless' in Karma.config and corresponding script has been added to package.json.
When I run the npm test command inside vagrant(using Ubuntu 64-bit), it gives me this error:
FATAL:nss_util.cc(632)] NSS_VersionCheck("3.26") failed. NSS >= 3.26 is required. Please upgrade to the latest NSS, and if you still get this error, contact your distribution maintainer.
I tried updating the NSS version by running the below command:
sudo apt-get install --reinstall libnss3 but still no luck.
Is there anything that I am missing or doing incorrectly?