how to place and use headless chrome binary on jenkins (linux) instance - jenkins

actually i am struggling with absence of bigger picture on how to proceed , here is the case :
I have protractor test suite running headless using Chrome 60 (beta) binary by giving binary location in chrome options in windows environment.
I want to port this to available CI CD Jenkins instance (linux) and run headless there. I can think of two approaches :
Approach 1 :
Install chrome plugin in jenkins , so chrome becomes available to be driven by chrome driver < webdriver modules .so that i can use jenkins job as shown below :
npm install
npm run start (from script , runs webdriver-manager start )
npm run update (from script , runs webdriver-manager update )
npm run test (from script , runs protractor protactor.conf.js )
Approach 2 : install chrome as module like other npm modules .then
npm install
npm run start (from script , runs webdriver-manager start )
npm run update (from script , runs webdriver-manager update )
npm run test (from script , runs protractor protactor.conf.js )
I have looked into simple-headless-chrome , headless-chromium , chrome-runner npm modules , but not able to understand how these will work .
My understanding is to somehow have chrome binaries in node_modules and give path for chrome binaries in chrome options so that chrome driver can find it .
Can anyone enlighten me a little bit about bigger picture and how things will workout for Second approach .As i want dont have access to get chrome plugin installed on jenkins server and want to keep my setup independent.(nodejs and npm , java etc are available in jenkins)

About "using Chrome 60 (beta) binary by giving binary location in chrome options in windows environment.", you don't really need to, protractor gives you a way to specify tags to run the chrome binary:
https://github.com/angular/protractor/blob/master/docs/browser-setup.md#using-headless-chrome
I don't think you have a node module to install chrome, or at least something reliable as the google chrome itself, so what I've done was installing google chrome on my ubuntu server that runs the jenkins slave, and you now have a google-chrome binary you can run with --headless.
Previously my jenkins slave was running on a CentOS but I had a really hard time setting up chrome on it so changed to ubuntu.

Related

Why does upgrading chome and chrome driver stop web application from loading

Im Running E2E testing on a web application in Jenkins using a centos node with webdriver IO.
Chrome :google-chrome-stable-96.0.4664.110-1.x86_64.rpm
Chrome driver:
sh 'sudo yum info google-chrome-stable | grep Version > chromeOutFile'
def CHROME_VERSION = readFile('chromeOutFile')
def Version = CHROME_VERSION.split('Version :')
def VersionNumber = Version[1].trim()
sh "./src/main/web/node_modules/protractor/bin/webdriver-manager update --versions.chrome=${VersionNumber}"
Id like to update this to user the latest version of chrome with a corresponding chrome driver.
Webdriver IO config:
services: [['chromedriver', {
chromedriverCustomPath: '../node_modules/webdriver-manager/selenium/chromedriver_96.0.4664.110'
}]],
Problem: when I try to use a more upto date version, even if its chromedriver_97.0.4692.99, my web application no longer starts up in Jenkins. When I try to visit the url, the screen shot just shows a blank screen. Im not sure the application is even loading.
Why does it only work with 96 but not others?
I tried to map the version of chrome with an appropriate version of chrome driver using https://chromedriver.storage.googleapis.com/LATEST_RELEASE_97.0.4692 but that still doesnt work for me.
Running tests:
cd e2e && wdio run wdio.ci.conf.ts --suite access --logLevel=info
+ lsb_release -d
Description: CentOS Linux release 7.9.2009 (Core)
Thanks
Have you tried to check memory limits? I had a similar problem with automated testing and had to change memory limits to either 1) limit chrome's memory or 2) pre allocate a set amount of memory ahead of time from my webserver if you are testing on the same device.

How do I run a script file in Windows?

I am trying to build Pyodide from source on Windows. In their documentation they recommend using Docker. From the documentation:
1 Install Docker
2 From a git checkout of Pyodide, run ./run_docker or ./run_docker --pre-built
3 Run make to build.
I don't understand how to run ./run_docker?
I don't even know exactly what the file is. Is it a shell script?
Combining your question, "How do I run a script file in Windows?", with the information provided (you want to run a file called run_docker from the Pyodide project) you should get started by installing the Windows Subsystem for Linux version 2 (WSL). After you install WSL, you will need to open a command prompt, run bash to enter the Ubuntu linux distribution. From here you should follow the steps for building on Linux. When you run into a problem you can search the internet for solutions related to "Linux" or "Ubuntu".

Is there a way to see in cypress electron browser some logging?

I am using cypress to test my web site. Everything works great but there is one page that opens fine when I am running the test using chrome but if I try to run that against headless or regular electron the lhes simply don’t open.
I am assuming that there must be something on my code that is not working on the chromium version that electron uses (61) that do works the version that chromes uses (75).
Is there a way to debug or check some logging on what is not being able to execute? The console for electron does not display anything.
Any ideas?
You can show console.log messages from Electron by enabling a subset of DEBUG logs.
Like so:
Windows:
npm i -g cross-env
cross-env DEBUG=cypress:server:browsers:electron cypress run...
macOS or Linux:
DEBUG=cypress:server:browsers:electron cypress run...
After adding these two env variables Cypress started showing console.log output on the terminal:
ELECTRON_ENABLE_LOGGING=true DEBUG=cypress:electron $(npm bin)/cypress run ...

Cant find Angular error when running headless Chrome Protractor tests on Linux CentOS trying with both xvfb and not

Bit of a long winded one....
I have a Jenkins instance running on a Linux CentOS box. I have a Jenkins job on there which should run Protractor tests using Chrome headless, I have tried a number of configurations including using Xvfb and not using Xvfb and I always get the same result where the tests start to run and do the first browser.get command but after a few seconds the tests error with:
E/protractor - Could not find Angular on page
After the tests run a HTML report is generated and all the screesnhots are blank.
Here's the relevant code and config I'm using...
my protractor conf.js
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: [
// IMPORTANT: needed due to issue with versions of selenium and chromedriver
"--headless",
"--no-sandbox",
"--window-size=1024x768"
]
}
},
My jenkins config I run shell command...
npm -g install protractor
webdriver-manager update
webdriver-manager start &
Then to run the tests I use...
xvfb-run protractor --baseUrl='https://myurl.com' conf.js
I have xvfb configured in Jenkins and installed on the CentOS box. I have tried without using xvfb as apparently later versions of Chrome don't need it.
The same tests are also running headless locally on OSX without any issue so the only difference is the operating system I think.
I'm struggling to work out what else it might be.

Unable to get chrome driver working through jenkins

I am unable to get chrome driver working via Jenkins. My tests run fine from a terminal window but I wish to run them from Jenkins in headless mode.
I have the latest recommended version of chrome driver installed and Chrome version 28.0.1500.71. Chromedriver has been placed on my path at /Usr/bin.
However when I attempt to run the tests from Jenkins I get an error message:
"Unable to either launch or connect to Chrome. Please check that ChromeDriver is up-to-date. Using chrome binary at: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome (Selenium::WebDriver::Error::UnknownError)"
I have also tried installing previous version of chrome and chromedriver but I get the same error message.
So after some investigation I found that in order to run headless tests via Jenkins you may need to have installed xvfb. (i say may because I am not 100% sure if this is correct) So I installed xvfb via Xquartz and the xvfb file is also on my path at /Usr/bin.
However even after doing the above with Xvfs I still get the error. Xvfs appears to start successfully as I get the message: Xvfb starting$ /Usr/bin/Xvfb :1 -screen 0 1024x768x24 -fbdir /Users/Shared/Jenkins/Home/2013-07-15_16-24-193595155347701391882xvfb in the console output in Jenkins.
Anybody have any idea what I am doing wrong? I am new to the world of Macs so there may be something I am missing.
Any help would be greatly appreciated!!
Managed to get this sorted. Instead of enabling Xvfb in the job configuration build environment section, I ran it using a terminal command and it now works. So my terminal command is now: xvfb-run cucumber --tags #automated - So this issue can be closed

Resources