Chrome has now a native headless mode. I'd like to set this up to run Selenium tests on TravisCI, without Xvfb.
Are there easy to install Headless Chrome binaries on TravisCI, as most of recipes only start with compiling Headless Chrome from source
Does Selenium need any specific hints when used with Headless Chrome
Travis offers the usage of the chrome add-on. If you want to run your build on Linux(trusty) all you have to do is specify chrome in your travis-file and start the browser in headless-mode before you start testing.
dist: trusty
addons:
chrome: stable
before_install:
- # start your web application and listen on `localhost`
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
Related
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.
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
I've read about the Chrome Headless from developers.google said we can run the Google without UI. Quote from that link :
Headless Chrome is shipping in Chrome 59. It's a way to run the Chrome
browser in a headless environment. Essentially, running Chrome without
chrome! It brings all modern web platform features provided by
Chromium and the Blink rendering engine to the command line.
Why is that useful?
A headless browser is a great tool for automated testing and server
environments where you don't need a visible UI shell. For example, you
may want to run some tests against a real web page, create a PDF of
it, or just inspect how the browser renders an URL.
This is really great feature, so I do some experiment with this cool feature. The idea is to taking snapshot as the document site by do call of chrome.exe from Windows Command Prompt, as follow :
chrome --headless --disable-gpu --screenshot https://www.chromestatus.com/
After do several times and following the instruction from these site. I got nothing. I don't get any picture or screenshot with name screenshot.png as document mention it before Running with --screenshot will produce a file named screenshot.png in the current working directory.
From this document also said about version,
Caution: Headless mode is available on Mac and Linux in Chrome 59.
Windows support is coming in Chrome 60. To check what version of
Chrome you have, open chrome://version.
after do some check with suggested before, I run chrome://version on my Chrome on Windows x64 Machine and got some result :
Google Chrome 62.0.3202.94 (Official Build) (64-bit) (cohort: Stable)
Revision 4fd852a98d66564c88736c017b0a0b0478e885ad-refs/branch-heads/3202#{#789}
What wrong? What i missed?
Thanks
After do some experiments. for --screenshot will save the image on the same level as chrome.exe location and that will be mean save on Program Files.
So we need need to combine parameter names and arguments with a =
--screenshot="D:\screen.png" will work, otherwise Chrome writes to it's installation folder. Big design flaw, no software should use it's installation folder as a working directory.
Here are the complete argument :
chrome --headless --enable-logging --disable-gpu --screenshot="D:\screen.png" "https://www.chromestatus.com/"
When I try to run Chrome in Headless, REPL mode with:
chrome --headless --disable-gpu --enable-logging --repl
I'm getting an endless spam of
{"result":{"type":"undefined"}}
It's pretty much the same problem as described here:
Headless Chrome REPL not working
But since I'm trying to run it on Windows 7, I'm not sure if that solution applies to me
Edit:
I forgot to add, I'm using a 62.0.3202.94 Chrome version
Chrome version : 58
OS : Ubuntu 16.04
I wanted to take screenshot after blocking ads in chrome --headless mode.For which I have added an entry in default_apps/external_extensions.json for property external_update_url. (Ref : Link)
When I run the application with
google-chrome --remote-debugging-port=9222 --disable-gpu
I am able to see that the adblock plugin is active and blocking adds,While when I tried to run
google-chrome --headless --remote-debugging-port=9222 --disable-gpu
(i.e in headless mode) the adblock plugin is not running or enabled.
I verified the fact by taking screenshot of viewport in both modes. Can anyone please help me to run the adblock plus extension for headless mode.
Headless Chrome does not support extensions, but you can render Chrome on a virtual display. See Is it possible to run Google Chrome in headless mode with extensions?