Hacker News new | ask | show | jobs
by zelo 2525 days ago
It's probably because in the meantime dom nodes has been replaced by new ones.

Selenium has it's quirks but when you understand how it works and it's limitations and user centric philosophy there is nothing that can stop you from writing rock solid stable tests.

1 comments

Sorry I didn't defined the problems clearly and thank your for your help. I am using selenium using python for web automation, not testing. The latter problem was by and large solved by subclassing WebDriverWait by adding common Exceptions related to nodes staleness. The former problem was tackled by writing a for loop detecting changes of the context to know if WebElement.click() fails silently.

The thing is I have to write these workarounds everywhere. What's more, I inject javascript code a lot to avoid nodes staleness caused by network latency. I believe selenium is not designed for writing lots of javascript. And javascript code in a string of python can not be linted, which increases debugging workload.

To this point, the cost of these hacks is too much in my project. I find puppeteer play nicely with javascript after trying. But the difference and reliability between waitFor() in puppeteer and WebDriverWait() in selenium still remain questionable.

I am wondering if using puppeteer can ease pains mentioned above.

Selenium for sure doesn't fit in your use case then :). I pointed "user-centric approach" because selenium focuses on allowing only things normal user could do in normal user way which is limiting for automation but it's a blessing if you want to look as close to the real user as you can. I worked on solving google ReCaptcha v2/v3 at bigger scale and it's been a solid advantage.

> And javascript code in a string of python can not be linted, which increases debugging workload.

If you use PyCharm or any other JetBrains IDE you can use `Language Injections` [0]

> I am wondering if using puppeteer can ease pains mentioned above.

I'm not sure about puppeteer but Chrome DevTools Protocol [1] (I think this is what puppeteer use under the hood, but I'm not sure) may be interesting for you because it gives low level access to browser mechanisms like injecting code before page load, request interception or separate browser contexts between separate tabs.

[0] https://www.jetbrains.com/help/pycharm/using-language-inject...

[1] https://chromedevtools.github.io/devtools-protocol/

Thank you. The Language Injections feature amazes a vim user, though similar limited plugin exists.