655 points · by cpeterso · 2y ago · 90 comments
I have yet to see a browser automation tool that does not use localhost bound TCP sockets. Apart from that, most tools do not offer strong authentication -- a browser is spawned and it listens on a socket and when the controlling application connects to the browser management socket, no authentication is required by default, which creates hidden vulnerabilites.
While browser sessions may only be controlled by knowing their random UUIDs, creating new sessions is usually possible to anyone on 127.0.0.1.
I don't know really, it's quite possible I'm just spreading lies here, please correct me and expand on this topic a bit.
By default, Playwright launches this way and you have to specifically enable the tcp listening.
Happy to be wrong here if anyone can correct me. The idea of all tests confirming both functionality and accessibility in one go would be much nicer than testing against hard coded test IDs and separately writing a few a11y tests if I'm offered the time.
If you really want gold standard screen reader testing, there’s no substitute for testing with actual screen readers. Each uses the accessibility tree in its own way. Remember also that each browser has its own accessibility tree.
When UI is only visual noise and has no impact on functionality, I don't see much value in automated testing for it. In my experience these cases are often related to animations and notoriously difficult to automate tests for anyway.
When UX diverges between UI and the accessibility tree, I'd really expect that to be the exception rather than the rule. There would need to be a way to test both in isolation, but when one use case diverges down two separate code paths it's begging for hard to find bugs and regressions.
Totally agree on testing with screen readers directly though. I can't count how many weird differences I've come across between Windows (IE or Edge) and Mac over the years. If I remember right, there was a proposed spec for unifying the accessibility tree and related APIs but I don't think it went anywhere yet.
Only Windows and MacOS though, which is a problem for build pipelines. I too would very much like the page descriptions and the accessibility inputs to be the primary way of driving a page. It would make accessible access the default, rather than something you have to argue for.
Skimming through their getting started, I wonder how translations would be handled. It looks like the tests expect to validate what the actual screen reader says rather than just the tree, for example their first test shows finding the Guidepup header in their readme my waiting for the screen reader to say "Guidepup heading level 1".
If you need to test different languages, you'd have to match the phrasing used by each specific screen reader when reading the heading descriptor and text. All your tests are also actually vulnerable to any phrasing changes made to each screen reader. If VoiceOver changed something it could break all your test values.
I bet they could hide that behind abstractions though, `expectHeading("Guidepup", 1)` or similar. Ideally it really would just be a check in the tree though, avoiding any particular implementation of a screen reader all together.
We started with WebSockets because that supports more use cases (e.g. automating a remote device such as a mobile browser) and because building on the existing infrastructure makes specification easier.
It's also true that there are reasons to prefer other transports such as unix domain sockets when you have the browser and the client on the same machine. So my guess is that we're quite likely to add support for this to the specification (although of course there may be concerns I haven't considered that get raised during discussions).
Like, a wrapper that does my history and tabs and book marks - but let's me move from rendering in Chrome or Gecko or Servo or whatever.
JSDom in the Nodejs world offers a peak into what that might look like - though it is lacking a lot of browser functionality making it impractical for most use cases.
> Cross-browser. Playwright supports all modern rendering engines including Chromium, WebKit, and Firefox.
I used to have so many issues with Selenium and so only used it in must have situations defaulting to capybara to run out specs.
The license notice you mention is indeed there [2], but also isn't surprising they wouldn't reinvent the wheel for those things they wrote earlier and that simply work. Even if they didn't directly use code, Microsoft would be silly to not add it given their previous involvement with puppeteer.
Even if it was originally a fork, they are such different products at this point that at best you could say that playwright started out as a fork (Which, again, it did not as far as I can tell).
[1] https://github.com/microsoft/playwright/commit/9ba375c063448...
[2] https://github.com/microsoft/playwright/blob/3d2b5e680147577...
> I think Playwright depends on forking the browsers to support the features they need, so that may be less stable than using a standard explicitly supported by the browsers, and/or more representative of realistic browser use.
(And for Safari/WebKit to support it as well, but I'm not holding my breath for that one.) Though I hope Playwright will adopt BiDi at some point as well, as its testing features and API are really nice.
My hot take on things: When the Puppeteer team left Google to join Microsoft and continue the project as Playwright, that left Google high and dry. I don't think Google truly realized how complementary a browser automation tool is to an AI-agent strategy. Similar to how they also fumbled the bag on transformer technology. (The T in GPT)... So Google had a choice, abandon Puppeteer and be dependent on MS/Playwright... or find a path forward for Puppeteer. WebDriver BiDi takes all the chocolatey goodness of the Chrome DevTools Protocol (CDP) that Puppeteer (and Playwright) are built on... and moves that forward in a standard way (building on the earlier success of the W3C WebDriver process that browser vendors and members of the Selenium project started years ago.)
Great to see there's still a market for cross-industry standards and collaboration with this announcement from Mozilla today.
I'm not a heavy user of these tools, but I've dabbled in this space.
I think Playwright is far ahead as far as features and robustness go compared to alternatives. Firefox has been supported for a long time, as well as other features mentioned in this announcement like network interception and preload scripts. CDP in general is much more mature than WebDriver BiDi. Playwright also has a more modern API, with official bindings in several languages.
One benefit of WebDriver BiDi is that it's in process of becoming a W3C standard, which might lead to wider adoption eventually.
But today, I don't see a reason to use anything other than Playwright. Happy to read alternative opinions, though.
One of the benefits of using Selenium is the extensive ecosystem surrounding it. Things like Selenium grid make parallel and cross-browser testing much easier either on self hosted hardware or through services like saucelabs. Playwright can be used with similar services like browserstack but AFAIK that requires an extra layer of their in-house SDK to actually make it work.
Selenium also supports more browsers, although you can wonder how much use that is given the Chrome dominance these days.
Another important difference is that Playwright really is a test automation framework, where Selenium is "just" a browser automation library. With Selenium you need to bring the assertion library, testrunner, reporting in yourself.
You're free to fork it and even monetize your fork.
(Actually, millions... but you wouldn't know it if all you read were comments on HN and Reddit.)
If you used playwright, write tons of tests, then hear about some new browser feature you want to target to get ahead of your competition, you'd have to refactor all of your tests away from playwright to something that could target chrome canary or firefox nightly or safari technology preview.
Has that changed?
Some example use cases would be writing some basic tests to validate a UI or automate some form-filling on a javascript based website with no API.
Playwright only really gets better than puppeteer if you’re doing actual website testing of a website you’re building which is where it shines.
Selenium is awesome, and probably has more guide/info available but it’s also harder to get into.
what does Webdriver Bidi do and what do you mean by "taking the good stuff from CDP"
I don't want to run my scrapes in the cloud and pay a monthly fee
I want to run them locally. I want to run LLM locally too.
I'm sick of SaaS
You could probably figure out how to connect Llama to Puppeteer. (If no one has done it, yet, that would be an awesome project.)
There is a extension api that exposes a CDP connection [1][2]
You can create a Puppeteer.Browser given a CDP connection.
You can bundle Puppeteer in a browser (we do this in Lighthouse/Chrome DevTools[3]).
These two things is probably enough to get it working, though it may be limited to the active tab.
[1] https://chromedevtools.github.io/devtools-protocol/#:~:text=...
[2] https://stackoverflow.com/a/55284340/24042444
[3] https://source.chromium.org/chromium/chromium/src/+/main:thi...
Talking about WebDriver (BiDi) in general rather than Puppeteer specifically, it depends what exactly you mean.
Classic WebDriver is a HTTP-based protocol. WebDriver BiDi uses websockets (although other transports are a possibility for the future). Script running inside the browser can create HTTP connections and create websockets connections, so you can create a web page that implements a WebDriver or WebDriver BiDi client. But of course you need to have a browser to connect to, and that needs to be configured to actually allow connections from your host; for obvious security reasons that's not allowed by default.
This sounds a bit obscure, but it can be useful. Firefox devtools is implemented in HTML+JS in the browser (like the rest of the Firefox UI), and can connect to a different Firefox instance (e.g. for debugging mobile Firefox from desktop). The default runner for web-platform-tests drives the browser from the outside (typically) using WebDriver, but it also provides an API so the in-browser tests can access some WebDriver commands.
local scraping howto - https://www.freecodecamp.org/news/web-scraping-in-javascript...
local LLM framework - https://ollama.com/
I’d like to advocate for more focus on these accessibility trees. They are a distillation of every semantic element on the page, which makes them fantastic for snapshot “tests” or BDD tests.
My dream would be these accessibility trees one day become standardized across the major browser engines. And perhaps from a web dev point-of-view accessible from the other layers like CSS and DOM.
I haven't dug into it and am quite possibly incorrect, hence the request for confirmation!
We had to change Firefox so it could be automated with WebDriver BiDi. The Puppeteer team had to change Puppeteer in order to implement a WebDriver BiDi backend, and to enable specific support for downloading and launching Firefox.
As the article says, it was very much a collaborative effort.
But the announcement is specifically about the new release of Puppeteer, which is the first to feature non-experimental support for Firefox. So that's why the title's that way around.
This project is about 5 years too late to have a purpose. I am flummoxed why anybody would do this in 2024?
> Proxies included..., Auto Captcha Solving, Advanced Stealth Mode
Other than that, like everything else, a hosted service is always an option and not contradict with you being able to host that service directly, they're just for different sets of constrains.