TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Running Headless Selenium with Chrome

49 点作者 iamchrisle将近 12 年前

6 条评论

evmar将近 12 年前
For all the many problems with X11, it&#x27;s still pretty cool that you can run something as complicated as Chrome in a headless manner just by running another program (xvfb) that speaks the protocol.<p>(I keep intending to hack Blink into a state where it can run truly headless, like a library, so that hacks like the above aren&#x27;t necessary.)
评论 #6237844 未加载
diminoten将近 12 年前
One thing I always think is worth mentioning in posts like this is that the above setup (and any setup using Selenium, really) is going to be <i>super</i> slow. More than one order of magnitude slow, when compared to direct HTTP requests.<p>It&#x27;s only ever worth using Selenium when you <i>literally</i> can&#x27;t do anything else to get your testing done.<p>Edit: Going through my bookmarks bar and found this, from 2008 - <a href="http://www.alittlemadness.com/2008/03/05/running-selenium-headless/" rel="nofollow">http:&#x2F;&#x2F;www.alittlemadness.com&#x2F;2008&#x2F;03&#x2F;05&#x2F;running-selenium-he...</a><p>Might help anyone if they run into issues.
评论 #6238415 未加载
hoov将近 12 年前
One odd issue that I ran into was that Chrome (and Firefox) wouldn&#x27;t always go fullscreen. I had to install a window manager that defaulted to fullscreen. In particular, I went with Ratpoision: <a href="http://danielwebb.us/software/ratpoison/" rel="nofollow">http:&#x2F;&#x2F;danielwebb.us&#x2F;software&#x2F;ratpoison&#x2F;</a>
hedgehog将近 12 年前
I&#x27;ve had good luck with a similar setup (somewhat inspired by IMVU&#x27;s) doing integration testing on an Ember app: Chromium + chromedriver inside a VirtualBox Vagrant instance using Xvfb + ratpoison + x11vnc. My tests run from a modified version of Wai Yip Tung&#x27;s HTMLTestRunner (Python unittest module underneath) so reloading the tests tab in a browser on my dev machine reruns the tests. All of the tests are written in Python. If something gets stuck you open up a VNC client and poke around manually. It&#x27;s a bit of work to set up and the tests can be a bit slow but I&#x27;d recommend it when you really need to test in a browser.
_karthikj将近 12 年前
How does it differ from PhantomJS&#x2F;CasperJS (headless webkit)? I have been using these for a while and they can do pretty much everything that you can do in a browser.
评论 #6237834 未加载
评论 #6237964 未加载
评论 #6239339 未加载
jonstjohn将近 12 年前
I&#x27;ve experimented with running headless tests using Firefox, in hopes of getting a good performance boost in terms of test speed. The results actually did not indicate much of a difference. If anything, FF in headless mode on CentOS ran slower than on Windows.<p>That&#x27;s not to say there aren&#x27;t good use cases for running headless browsers with Selenium. One huge benefit is not needing to run Windows VMs.
评论 #6237875 未加载