Live data from Hacker News

Running feature specs with Capybara and Chrome headless

drivy.engineering

1–10 of 35 posts

Re: Running feature specs with Capybara and Chrome headless

#4
post #2

"It is also supposed to improve memory usage and stability" Did you do a comparison of memory against phantomJS?

Words from PhantomJS ex-maintainer[0]:

> I think people will switch to it, eventually. Chrome is faster and more stable than PhantomJS. And it doesn't eat memory like crazy.

[0] https://groups.google.com/forum/#!msg/phantomjs/9aI5d-LDuNE/...

Re: Running feature specs with Capybara and Chrome headless

#5
Earlier this month I wrote an ETL extractor using Capybara & headless browser (to work-around a lack of API - PS: only do that as a last resort!).

One thing I learned and wanted to warn about here is that Chrome headless currently doesn't support file downloads [1].

PhantomJS won't work either (unless you use a custom build) [2].

I also tried with capybara-webkit, but no luck either [3].

The only driver which ultimately allowed me to download files at this point was Selenium + Firefox (with some tweaking on profile options browser.download.dir, browser.download.folderList = 2, browser.helperApps.neverAsk.saveToDisk set to the MIME type of files to be downloaded).

[1] https://bugs.chromium.org/p/chromium/issues/detail?id=696481

[2] https://github.com/ariya/phantomjs/issues/10052

[3] https://github.com/thoughtbot/capybara-webkit/issues/691

Re: Running feature specs with Capybara and Chrome headless

#6
Chrome headless migration has been my bane for the last two weeks. It's almost ready, but not yet.

The short version of what's wrong: chrome headless does not support extensions. The chromedriver used by selenium works via starting chrome with an automation extension that gives it certain needed functionality. So things like setting the window size, taking screenshots, and a few other important features just cause chromedriver to crash or hang.

There's bugs filed and some clever googlers are trying to fix it all- but it's not ready for our purposes yet. I don't want to rewrite dozens of tests that work with phantomjs to get around chrome's bugs.

Re: Running feature specs with Capybara and Chrome headless

#7
Kind of off topic, but. Is running automation as complicated as this? I recently wanted to log in to a website, click some page and download a .csv file. I saw that chrome can be run headless, nice.

So I opened it headless and there's this REPL, nice I can do JS directly into the website. Now how do I automate this.

This leads me into all sorts of things that doesn't seem related at all (I is, but still). Selenium stuff, automation setups, drivers, language bindings, chrome-api-stuff and no end in sight.

All I want is something like "chrome -headless -js script-flow.file http://URL"

Am I to overwhelmed or is there no simple way without buttloads of 3rd party tools and setups required?

Re: Running feature specs with Capybara and Chrome headless

#8
post #2

"It is also supposed to improve memory usage and stability" Did you do a comparison of memory against phantomJS?

In fact no we didn't do any kind of benchmark. It's an assumption made of feedback from other users. As we knew we wanted to switch to headless Chrome anyway, we didn't investigate more into this part.

Re: Running feature specs with Capybara and Chrome headless

#9
post #6

Chrome headless migration has been my bane for the last two weeks. It's almost ready, but not yet. The short version of what's wrong: chrome headless does not support extensions. The chromedriver used by selenium works via starting chrome with an automation extension that gives it certain needed functionality. So things like setting the window size, taking screenshots, and a few other important features just cause ch…

Indeed, some features are not supported yet (setting size, alerts, ...). We're lucky not to use too many of them in our actual test suite!

Re: Running feature specs with Capybara and Chrome headless

#10

Kind of off topic, but. Is running automation as complicated as this? I recently wanted to log in to a website, click some page and download a .csv file. I saw that chrome can be run headless, nice. So I opened it headless and there's this REPL, nice I can do JS directly into the website. Now how do I automate this. This leads me into all sorts of things that doesn't seem related at all (I is, but still). Selenium st…

Yeah, it's actually way simpler than that since chrome (and I think Firefox now too) is exposing a API for driving the browser, what you're after is the remote debugging protocol: https://chromedevtools.github.io/devtools-protocol/

But, you have bunch of things that abstract that for you, so you don't have to implement things hitting that API manually. Anyways, here is a handy document from Mozilla on the protocol too: http://searchfox.org/mozilla-central/source/devtools/docs/ba...

Post reply on HN