Unable to get chrome driver working through jenkins - 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

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.

Most basic Selenium webdriver "Hello World" fails miserably

My selenium webdriver 'hello world' program is error-ing. Apologies since I am very new to this.
I spun up a new Ubuntu image and here is my setup:
Ubuntu 18.04 with Google Chrome installed
Ruby on Rails
selenium-webdriver gem installed
VNC is installed
My 'hello world' program:
require "selenium-webdriver"
**driver = Selenium::WebDriver.for :chrome**
driver.navigate.to "http://www.google.com"
element = driver.find_element(:name, 'q')
element.send_keys "Hello Selenium WebDriver!"
element.submit
puts driver.title
This spits out the error:
/home/user/.rvm/gems/ruby-2.6.3/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/response.rb:72:in `assert_ok': unknown error: Chrome failed to start: exited abnormally (Selenium::WebDriver::Error::UnknownError)
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706),platform=Linux 5.0.0-1028-gcp x86_64)
(This error happens at the boldfaced line of code)
I checked with whereis command for google-chrome and google-chrome-stable. They are both in /usr/bin/
I also have VNC installed and I am looking at the operating system. When I run this program, I am hoping for Chrome to pop out but nothing happens.
Is Selenium supposed to start chrome (visible to me in VNC)? In any case, what am I doing wrong?
A few things can be going wrong here.
First things first, make sure you have an up-to-date copy of chromedriver installed on the machine. You can extract and place the executable in any location that's included in $PATH (echo $PATH to see where these directories are located).
If you're still having issues, it's worth trying to add the following options to the driver initialization, like this:
options = Selenium::WebDriver::Chrome::Options.new
options.headless!
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
driver = Selenium::WebDriver.for :chrome, options: options
If that works for you, this may be an issue related to the x window manager that's installed (or not installed). Alternatively to messing around with something like that, you could check out XVFB to run selenium tests in.

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 ...

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

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.

EOFError: end of file reached -- all js specs are crashing Capybara with an older Chrome driver

Capybara using Chrome driver with setup:
spec_helper
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
Capybara.javascript_driver = :chrome
I appear to be getting
EOFError:
end of file reached
On all of my Javascript tests when I run them with chrome driver.
This appears to have began on or around Oct 27, 2016
Running with poltergeist they work fine.
• also when they crash they appear to open multiple instances of chrome which hang (but do not exit) see http://screencast.com/t/Worwl9d6Iuhr screenshot example
• these appear to affect only my javascript specs (:js => true in Capybara)
• Rebooting my machine did not solve the problem
• My Chrome Mac OS X is currently at 54.0.2840.71
• I'm not sure when sub-sub-point version 71 got released since of course Chrome doesn't tell you or even seem to have it available in some kind of update history. The public information says sub-point version 54.0.2840 was released 2016-10-12 but it doesn't specify when sub-sub-point version 71 was released
• I can reproduce the effect on both my code on master, as well, I have a specific memory of running these specs with Chrome driver earlier in this week, so I am strongly suspecting that Chrome did a sub-sub-point release here and broke this.
if anyone else can confirm I would appreciate it. otherwise, if I find a local problem, I will post answer here.
• Capybara 2.7.1
• selenium-webdriver 2.53.0
• I located the Chromedriver executable in my machine at /usr/local/bin/chromedriver [is this the right one -- I seem to have an older one in /Users/jason/bin/chromedriver ?]
$ which chromedriver
/usr/local/bin/chromedriver
$ /usr/local/bin/chromedriver -v
ChromeDriver 2.20.353124 (035346203162d32c80f1dce587c8154a1efa0c3b)
Upgrading Chrome Driver to 2.25 solved the issue
to do so via brew
$ brew unlink chromedriver
Unlinking /usr/local/Cellar/chromedriver/2.20... 1 symlinks removed
$ brew install chromedriver
==> Using the sandbox
==> Downloading https://chromedriver.storage.googleapis.com/2.25/chromedriver_mac6
######################################################################## 100.0%
==> Caveats
To have launchd start chromedriver now and restart at login:
brew services start chromedriver
Or, if you don't want/need a background service you can just run:
chromedriver
==> Summary
🍺 /usr/local/Cellar/chromedriver/2.25: 4 files, 10.3M, built in 7 seconds
hope this helps someone. I recently got this error when I was using capybara/poltergeist on a specific port (`., then I had a crashed test process still listening on a specific port.
If you are using rbenv, you can upgrade the chromedriver using brew than copy the executable :
for example, I'm using ruby 2.4.1:
$ cp /usr/local/Cellar/chromedriver/2.30/bin/chromedriver $HOME/.rbenv/versions/2.4.1/bin/
$ chmod +x $HOME/.rbenv/versions/2.4.1/bin/chromedriver
thank you

Resources