Live data from Hacker News

Puppeteer: Headless Chrome Node API

github.com

31–40 of 105 posts

Re: Puppeteer: Headless Chrome Node API

#31
post #8
post #4

The API looks nice and clean, but I'm puzzled by this from the FAQ: > Puppeteer works only with Chrome. However, many teams only run unit tests with a single browser (e.g. PhantomJS). Is this true? Do teams write unit tests but only test them in a single browser? With test runners like Karma and Testem, running tests concurrently in multiple browsers is easy. You'd be throwing away huge value if for some reason you o…

From my experience most teams only test against a single browser, yes. It's however nice to have the option to switch to another browser when debugging a browser-specific bug. From what I've seen in practice, for a lot of teams and projects, running tests concurrently across multiple browsers isn't easy as you claim. Once you have a database involved and not a perfectly clean setup, concurrent testing can become a ha…

It's also quite easy to run Chrome and/or Firefox for free in CircleCI or TravisCI. Safari and Edge are non-trivial to test in those environments. (I think you can get Safari if you tell CircleCI you're an iOS app and hack your way over to Safari from there, but I don't know if you can even test Edge in the popular CI stacks.)

Re: Puppeteer: Headless Chrome Node API

#32
post #30

Would be nice if it was possible to change the proxy settings for each request or for each session. Last time I checked it was only possible with the C API.

The request interception API might be able to satisfy your usecases: https://github.com/GoogleChrome/puppeteer/blob/master/docs/a...

Outside of that, Chrome doesn't currently support changing a network proxy dynamically, let alone for individual (and overlapping) requests.

Re: Puppeteer: Headless Chrome Node API

#35

Is there an equivalent of this for C#? I use Selenium a lot and find it annoying. Be interested to see if this is much better.

Under the covers this uses the DevTools protocol which has a number of projects around it: https://github.com/ChromeDevTools/awesome-chrome-devtools/#c...

A C# binding was added just recently: https://github.com/BaristaLabs/chrome-dev-tools

Re: Puppeteer: Headless Chrome Node API

#36

Earlier quoted context omitted.

We're fans of LucianoGanga's project (and of Chromeless, Doffy, Chrominator, Chromy, Navalia). I can tell you from personal experience that dealing with the raw DevTools Protocol isn't ideal for a developer writing an automation script, so it's clear there's demand for libraries with this higher-level API. Would love to know if there's a feature parity concern you have or what you'd like to see from puppeteer (or any…

Chromeless allows for the setting of cookies. I noticed in an issue for Puppeteer that it wasn't seen as a high priority. Our use-case (session based cookies) rely on a cookie being set in order for our PDF screenshots to work. Any chance you could give us some insight on when this may be available?

One of the puppeteer devs tells me he started on cookies last night. You'll see a PR soon. :)

Re: Puppeteer: Headless Chrome Node API

#37
It's funny how open the market for browser automation is. Everyone needs to switch off phantomJS in the next few years and is looking for the easiest option.

Sadly, there's probably no money on the line. But you will get your buggy software used by huge corporations for years to come!

Re: Puppeteer: Headless Chrome Node API

#38

Is there an equivalent of this for C#? I use Selenium a lot and find it annoying. Be interested to see if this is much better.

Not this, but on the C# front there's https://github.com/lefthandedgoat/canopy to ease Selenium use (Designed for F#, but exposes a C# API too)

Re: Puppeteer: Headless Chrome Node API

#40
post #9

So first there was Selenium's JSON Wire protocol, then came the W3C WebDriver spec and now we're back to browser-specific implementations? As someone who's tried/is trying to automate Firefox/Chrome/Safari/IE in a consistent fashion, my only question is: WHY?

(I don't have the full history, but from my experience...) When I first started using Selenium, it used browser-specific drivers that communicated directly with bespoke extensions/plugins/add-ons/what-have-yous. Then came Selenium Server which allowed for testing on remote machines. Then Grid allowed for simultaneous testing of many remote machines.

Due to the nature of browser plugins, they could only access information that the browser made available. Also, the dev's have consistently been of the opinion that they only care to simulate an end-user experience. (End user's only care about the webpage's presentation, not which headers were present per transaction.) Although, I suspect that early restrictions influenced that viewpoint.

It wasn't until much later that browsers started implementing their own automation channels; Chrome's Automation Extension and Debugging Protocol, Firefox's Marionette, etc. At the same time, browsers started putting additional security measures around plugins making it even more difficult to have consistent features across Selenium's drivers.

Which is why the WebDriver became an open specification instead various driver implementations. I believe, Microsoft was the first to implement their own driver, InternetExplorerDriver, for IE7+. Then ChromeDriver (powered by Chrome Automation Extension), GeckoDriver (Firefox translation to their Marionette driver), and SafariDriver is now baked into Safari 10.

Marionette is possibly the most interesting, but I lack experience with it. TMK it allows for automating the entire browser; both the webpage and the 'chrome' interface. Whereas Selenium, at best, could only simulate actions - like the back button - through Javascript. But, even with the Marionette's feature richness, you still don't get access to request and response information.

I think for most developers ("devs", "qa", "scrapers", etc.) there's very little appeal in moving away from Selenium because it would require maintaining multiple test suites. It gives consistent results and just works. If you want lower level information, it's fairly simple to either 1) just use a CLI client (curl, wget, etc.), or 2) a library libcurl, Requests(Python), Net::HTTP(Ruby), etc. etc. etc., or 3) setup proxy server. I do all of the above, each has it's own downsides clients and libs don't do any rendering themselves and proxies tend to rewrite transactions (ex. strip compression and add/remove/alter headers 'Content-Type: gzip').

Post reply on HN