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

我的未来我决定 提交于 2019-12-05 20:52:03

问题


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


回答1:


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/




回答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/



回答3:


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.



来源:https://stackoverflow.com/questions/15289425/how-to-run-browserschrome-ie-and-firefox-in-headless-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!