How to run browsers(chrome, IE and firefox) in headless mode?
Asked Answered
P

3

9

I want to integrate JSTestDriver with jenkins-CI. problem is that the build server does not have display. is there a way to run browsers headlessly?

Thanks

Pufahl answered 8/3, 2013 at 8:11 Comment(6)
heedlessly or headlessly means?Dirkdirks
Check Phantom JS.Bohon
+1 I am not sure if this helps with the Answer, but it help me THXAlvira
Phantom is WebKit based.i want to run tests on all browsers (IE etc) including the one that does not use WebKitPufahl
Pretty sure your server won't be able to test all browsers anyway, since IE is a windows browser, but the setup you describe sounds like a unix/linux machine.Buchenwald
you should accept answer or say why it did not work.Rosel
D
6

If your server is Linux, as mentioned, you can't run IE. But you can run other browsers like Firefox. The trick is to install XVFB on your Jenkins server which allows Firefox to run headless. I've used this setup and it works well.

http://www.alittlemadness.com/2008/03/05/running-selenium-headless/

Dandy answered 9/3, 2013 at 18:32 Comment(0)
U
2

Google Chrome now (Chrome 59 for Mac and Linux, Chrome 60 for Windows) has a headless mode built-in. It works cross-platform, and doesn't require any messing around with display devices, virtual machines, or anything like that. You can find a great Getting Started article by Eric Bidelman here, but here are the most key points:

You must launch the Chrome binary (on macOS it is located inside the Google Chrome.app bundle in the the Contents/MacOS directory) using --headless flag. It is currently also necessary to add the --disable-gpu flag, because GPU acceleration does not work properly in headless mode.

chrome --headless --disable-gpu [url/path/flags...]

As with standard non-headless Chrome, your test runner can communicate with Chrome using the dev tools interface if it's enabled by the --remote-debugging-port=[SOME_PORT] flag. However, if you'd just like to test it quickly by yourself you can use the --screenshot or --dump-dom flags to check out the contents of the page after loading.

chrome --headless --disable-gpu --dump-dom https://stackoverflow.com/
Utopianism answered 6/6, 2017 at 19:9 Comment(0)
C
2

Firefox, from version 55 on Linux and version 56 on Windows and macOS, now has a builtin headless mode.

At this moment (september 2017) I'm using a GNU/Linux based distribution, with Firefox 55, and a console command like this works fine: firefox --headless http://www.wikipedia.org, which is not something very useful, but it works because I see that the corresponding operating system process for Firefox keeps running.

This feature will gradually improve over time, so reading the official developers documentation is recommended, specially for those people interested in automated testing and continuous integration initiatives.

Calabro answered 6/9, 2017 at 14:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.