Live data from Hacker News

Helium: Lighter Web Automation with Python

github.com

1–10 of 53 posts

Re: Helium: Lighter Web Automation with Python

#6
post #4

How does it compare with the "usual suspects"? I mean Playwright, Selenium, Cypress, and Puppeteer.

It's more high-level. Instead of saying "click element with ID xv9873", you can say "click Download".

That's how Playwright works too

Re: Helium: Lighter Web Automation with Python

#7

Earlier quoted context omitted.

It's more high-level. Instead of saying "click element with ID xv9873", you can say "click Download".

That's how Playwright works too

Doesn't work for logging into HN:

    from playwright.sync_api import sync_playwright
    playwright = sync_playwright().start()
    browser = playwright.chromium.launch()
    page = browser.new_page()
    page.goto('https://news.ycombinator.com/login?goto=news')
    page.get_by_label('username').fill('mherrmann')
    # playwright._impl._errors.TimeoutError: Locator.fill: Timeout 30000ms exceeded.
I suspect Playwright expects there to be a for an element.

It does work with Helium:

    from helium import *
    start_chrome('https://news.ycombinator.com/login?goto=news')
    write('mherrmann', into='username')
The two scripts are equivalent, except Helium's works and is half as long.

Re: Helium: Lighter Web Automation with Python

#8
Importing * is universally discouraged by most Python linters and best practice docs. You can always "import helium as h" if you're looking to type less.

This looks largely like common workarounds that most people will write using Python-based browser automation. Most of the time, we accept that those capabilities aren't there by default because they are not explicit enough and can result in bugs and undefined behavior even when the elements that we expect to be on the page are actually there.

Given the adage "explicit is better than implicit", I worry that a layer like this might create more trouble than it's worth for the sake of readability. When we get into the nitty-gritty of browser automation, it might just make it harder to debug than going straight to Selenium or Playwright.

Re: Helium: Lighter Web Automation with Python

#9

Importing * is universally discouraged by most Python linters and best practice docs. You can always "import helium as h" if you're looking to type less. This looks largely like common workarounds that most people will write using Python-based browser automation. Most of the time, we accept that those capabilities aren't there by default because they are not explicit enough and can result in bugs and undefined behavi…

Importing * is universally discouraged by most Python linters and best practice docs.

Yup, I would never do it in a .py file. But I do it all of the time in the interpreter, which is what the video shows.

This looks largely like common workarounds that most people will write using Python-based browser automation. Most of the time, we accept that those capabilities aren't there by default because they are not explicit enough and can result in bugs and undefined behavior even when the elements that we expect to be on the page are actually there.

It sounds like you haven't tried Helium yet. I think you should, and see for yourself whether the trade-off you talk about actually exists.

Given the adage "explicit is better than implicit", I worry that a layer like this might create more trouble than it's worth for the sake of readability.

You could make the same argument about using C / assembly instead of Python. I suggest you try Helium before making statements about the "trouble" it may create. I believe you will find that there is no trouble.

Post reply on HN