Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

like image 990
krishan Avatar asked Nov 07 '22 19:11

krishan


1 Answers

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.

like image 79
luiscvalmeida Avatar answered Nov 15 '22 07:11

luiscvalmeida