4 ms·
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.c
by mherrmann 4y ago
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 https://github.com/mherrmann/selenium-python-helium
- maneesh 4y agoWow this is cool
- ZeKK14 4y agoDoes it solves the issues with virtual dom ? It's a pain to manage. The readme mentions iframes but not that.
- irjustin 4y agoSuper cool, but to be fair to the author, Clicking does seem easier still.
- mherrmann 4y agoUntil the web site changes and you have to re-record.
- CharlieDigital 4y agoPlaywright'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).
- eastendguy 4y agoYes! 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.
- odiroot 4y agoDo you know if there's a way to integrate Helium with Splinter?
- mherrmann 4y agoI don't know Splinter, sorry.
- hk1337 4y ago> 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.
- lyu07282 4y agoI 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
- eastendguy 4y agoI 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.