News for hackers. Stuff that matters.
Re:Web Automation: Don't Use Selenium, Use Playwright by mherrmann on Thursday November 10, 2022 @12:45AM (#33542752)
OP struggles with XPaths in complex DOMs. This is a solved problem. Use Helium [1] to write test code that acts on what the user sees:

  start_chrome('github.com/login')
  write('user', into='Username')
  write('pw', into='Password')
  click('Sign in')
I am the author of Helium. It's a wrapper around Selenium. It's fully open source. Under the hood, it uses Selenium 3, which is old. But boy does it work beautifully.

1: https://github.com/mherrmann/selenium-python-helium

Re:Web Automation: Don't Use Selenium, Use Playwright by maneesh on Thursday November 10, 2022 @01:17AM (#33542934)
Wow this is cool
Re:Web Automation: Don't Use Selenium, Use Playwright by ZeKK14 on Thursday November 10, 2022 @02:17AM (#33543254)
Does it solves the issues with virtual dom ? It's a pain to manage.

The readme mentions iframes but not that.

Re:Web Automation: Don't Use Selenium, Use Playwright by irjustin on Thursday November 10, 2022 @04:00AM (#33543933)
Super cool, but to be fair to the author, Clicking does seem easier still.
Re:Web Automation: Don't Use Selenium, Use Playwright by mherrmann on Thursday November 10, 2022 @04:41AM (#33544237)
Until the web site changes and you have to re-record.
Re:Web Automation: Don't Use Selenium, Use Playwright by CharlieDigital on Thursday November 10, 2022 @04:57AM (#33544379)
Playwright's selectors are very resilient.

Yes, your copy might change, but that is also a change in spec (whereas a change in DOM is not always a change in spec).

Re:Web Automation: Don't Use Selenium, Use Playwright by eastendguy on Friday November 11, 2022 @07:46AM (#33560145)
Yes! Recording xpath works fine in many cases, but once something on the website changes you are left with this auto-generated Xpath that you do not know how to change. Maintaining such a test is a nightmare and a waste of brain-cycles.
Re:Web Automation: Don't Use Selenium, Use Playwright by odiroot on Thursday November 10, 2022 @07:26AM (#33545447)
Do you know if there's a way to integrate Helium with Splinter?
Re:Web Automation: Don't Use Selenium, Use Playwright by mherrmann on Thursday November 10, 2022 @07:34AM (#33545522)
I don't know Splinter, sorry.
Re:Web Automation: Don't Use Selenium, Use Playwright by hk1337 on Thursday November 10, 2022 @07:47AM (#33545653)
> OP struggles with XPaths in complex DOMs.

A lot of the selenium code I have run up on people try and get the exact element they want on the first try and repeat the process several times instead of doing something like searching for a div, form, or some parent element that has all their elements then all they need is to search relative xpaths from that element.

Re:Web Automation: Don't Use Selenium, Use Playwright by lyu07282 on Thursday November 10, 2022 @08:01AM (#33545799)
I think a better approach is to take ui tests into account during development and use data attributes, like data-cy="input-username" or data-input-name="username"

Also the issue with Selenium isn't with finding elements on a page

Re:Web Automation: Don't Use Selenium, Use Playwright by eastendguy on Friday November 11, 2022 @07:42AM (#33560110)
I hate XPaths with a passion. They are powerful but a waste of time. The easiest solution is to use visual automation tools like UI Vision (web browser) or Sikuli (desktop). There you write something like "click: login" - and the word login is found not by parsing the DOM, but by using OCR.

Obviously such an automation runs much slower than any Selenium based automation, but it its sooo much easier to create and maintain, especially on complex websites with tons of Javascript and frameworks. I believe this is the future of causal (test) automation.