https://new.pythonforengineers.com/blog/web-automation-dont-use-selenium-use-playwright/ Python for Engineers * Home * About/Contact * Books * Blog Subscribe Web Automation: Don't Use Selenium, Use Playwright * Shantnu Tiwari Shantnu Tiwari Oct 27, 2022 * 2 min read For web automation/testing, Selenium has been the de facto "standard" since forever. It's simple to get started with and supports almost every programming language. My problem with it has been: It's good enough, but nothing more. It doesn't work that well with modern, Javascript framework heavy sites (Angular, React etc). I'm not saying it doesn't work-- just not too well. Another issue: While Selenium is supposedly "well documented", I found that as soon as you start going off the beaten path, examples are hard to find. Or there are 5 ways of doing something, none of which work very well. I really struggled with Selenium at a previous company. Selenium just couldn't parse the over-engineered Javascript framework we had, and I had to pile on hacks on hacks. So much so, I started looking at Javascript testing frameworks like Chai, Mocha, Cypress etc. The problem I found is that they require a completely different setup, and aren't easy to get started for someone from a Python background. There have been dozens of Selenium alternatives over the years; I tried quite a few. Almost everyone vanished after a few years (or they stopped updating and just abandoned the project). I suppose building a web testing framework is hard for volunteers. Enter Playwright I recently heard about Playwright. It looks really good and is built by Microsoft (who have started putting out good open-source tools like Vs Code). The Microsoft part is important, as it's more likely it will be supported over the years. The killer feature of Playwright is: You can automatically generate tests by opening a web browser and manually running through the steps you want. It saves the hassle I faced with Selenium, where you were opening developer tools and finding the Xpath or similar. Yuck Now, to be honest, there were always tools that would do this for you. But they were either a) Not very good b) Commercial and expensive The best part: Playwright "records" your steps and even gives you a running Python script you can just directly use (or extract parts from). I'm serious about the running part- I can literally record a few steps and I will have a script I can then run with zero changes. The other tools I tried before would give you small snippets of code that would sorta work, but not really, forcing you to jump thru hoops to get it working. Here, you get a ready made working script. p Playwright gives a fairly good implementation that I found works most of the time. It only occasionally missed a step, and in those cases I had to manually add it to the script. But I find Playwright's element discovery easier than Selenium's. Other benefits: You can record your runs as a video so you can view them later if you find any strange failures. Playwright also creates a detailed trace you can use to sort of "step thru" any failed runs. Cons? It's still new. That means bugs and not-as-good documentation. I found weird issues (when using the recorder) where I couldn't scroll down to the bottom of the screen in Playwright's Chromium, but could in a normal Chrome, forcing me to use other tricks to click the button. But I don't know if this was a Chromium or Playwright issue. But overall, for any new project, I'd always choose Playwright over any existing tools. Sign up to know when the next post is out, and get exclusive content Enter your email Subscribe How To Structure Your Godot Project (so You Don't Get Confused) This is a guest post by KP, whom I found by a very detailed and thoughtful comment he posted on Reddit /r/godot. If you like the post, make sure to check out his Youtube channel A tale as old as time. You just started to get familiar with Godot, * Shantnu Tiwari Shantnu Tiwari Oct 12, 2022 * 17 min read Learning Go as a Python Developer: The Good and The Bad I've been thinking about supplementing another language to Python for some time - mainly to cope with areas Python struggles with, or is a pain to use (which I'll go over in a minute). I had used C/C++ some years ago, but don't want to go back to them. C * Shantnu Tiwari Shantnu Tiwari Jul 18, 2022 * 3 min read My Poor Experience With Azure (or why I'm sticking with AWS) AWS has a lot of haters. Lots of horror cases where people thought they were on the free account but ended up with a $20,000 bill. We are told Azure has a much better model. You have to manually move to a paid service. No surprise bills. Like AWS, * Shantnu Tiwari Shantnu Tiwari Jul 13, 2022 * 3 min read Python for Engineers (c) 2022 Powered by Ghost