Live data from Hacker News

Running feature specs with Capybara and Chrome headless

drivy.engineering

21–30 of 35 posts

Re: Running feature specs with Capybara and Chrome headless

#21
I hear a lot of folks mentioning the pain working with headless chrome. This was the inspiration for Navalia, which is inspired by the API from nightmare. It also handles the case where you want to run simultaneous scripts by using new tabs (and even multiple chrome instances as well). It's still early in life, and I'm about to do another breaking release, but here is the repo https://github.com/joelgriffith/navalia

Re: Running feature specs with Capybara and Chrome headless

#22

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…

A nice quick solution for that is SlimerJS with Casperjs.

Re: Running feature specs with Capybara and Chrome headless

#23

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…

What does headless Chrome provide that a web scraper in any given language can't?

Re: Running feature specs with Capybara and Chrome headless

#24

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…

What does headless Chrome provide that a web scraper in any given language can't?

> What does headless Chrome provide that a web scraper in any given language can't?

Everything a web scraper could do, without reinventing all the infrastructure for handling web content (including JS/DOM interaction) from scratch. You could obviously do it all yourself in your language of choice,but why not focus on the application specific parts?

Re: Running feature specs with Capybara and Chrome headless

#25

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…

What does headless Chrome provide that a web scraper in any given language can't?

I was hoping it would let me automate a few tasks with a "user" flow (i.e. enter details, click, click). With e.g. curl or python I didn't even get through the login screens because they seem to require some special dealing with cookies, request/response cookies, smfd, itc, id_ado, _ip_xat and so on.

Basically auth on websites seems to require a whole bunch of stuff and I just started looking at simpler forms of automation instead. Still not sure which one I'll continue looking into.

(If anyone sees this, I am trying to log into iTunes Connect and Fabric and download metrics)

Re: Running feature specs with Capybara and Chrome headless

#27
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!

Just implemented headless testing for a rails app today, and discovered that alert support has been worked around in the latest Capybara (2.14.4).

https://github.com/teamcapybara/capybara/commit/12c100597093...

Re: Running feature specs with Capybara and Chrome headless

#28

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 ultimat…

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

Not true. At least with C# You can use

            var client = new WebClient();
            client.Headers[HttpRequestHeader.Cookie] = cookieString(driver);
            client.DownloadFile(reportURL, savePath + fileName + ".xlsx");
Along with:

            string cookieString(IWebDriver driver)
            {
                var cookies = driver.Manage().Cookies.AllCookies;
                return string.Join("; ", cookies.Select(c => string.Format("{0}={1}", c.Name, c.Value)));

            }
Edit: Just wanted to emphasize that this ensures all the steps you did to login won't be lost since you're using the logged in cookie. The idea is to use Selenium to get the download url and then use a regular download method using the selenium cookie.

Re: Running feature specs with Capybara and Chrome headless

#29

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…

What does headless Chrome provide that a web scraper in any given language can't?

Taking screenshots comes to mind. It's still extremely complicated to this day to get it right. Even with the likes of PhantomJS, Chrome Headless, etc.

Re: Running feature specs with Capybara and Chrome headless

#30

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…

Chrome headless is a bit on the edge. Selenium + Firefox/Chrome is pretty mature, and Selenium even publishes Docker images that remove a lot of setup complexity. Pick your favorite language, grab the requisite WebDriver gem/module/etc and point it at the container.

Additionally, for many use cases, the many browser automation SaaS's out there are a good solution.

Post reply on HN