Now Reading
Do not Use Selenium, Use Playwright

Do not Use Selenium, Use Playwright

2022-11-09 15:01:43

For net automation/testing, Selenium has been the de facto “customary” since perpetually. It is easy to get began with and helps virtually each programming language.

My drawback with it has been: It is ok, however nothing extra. It does not work that properly with fashionable, Javascript framework heavy websites (Angular, React and so forth). I am not saying it does not work– simply not too properly.

One other problem: Whereas Selenium is supposedly “properly documented”, I discovered that as quickly as you begin going off the crushed path, examples are exhausting to seek out. Or there are 5 methods of doing one thing, none of which work very properly.

I actually struggled with Selenium at a earlier firm. Selenium simply could not parse the over-engineered Javascript framework we had, and I needed to pile on hacks on hacks.

A lot so, I began Javascript testing frameworks like Chai, Mocha, Cypress and so forth. The issue I discovered is that they require a totally completely different setup, and are not simple to get began for somebody from a Python background.

There have been dozens of Selenium alternate options over time; I attempted fairly a couple of. Virtually everybody vanished after a couple of years (or they stopped updating and simply deserted the mission). I suppose constructing an online testing framework is tough for volunteers.

Enter Playwright

I just lately heard about Playwright. It appears to be like actually good and is constructed by Microsoft (who’ve began placing out good open-source instruments like Vs Code). The Microsoft half is vital, because it’s extra possible it is going to be supported over time.

The killer characteristic of Playwright is: You possibly can automatically generate tests by opening an online browser and manually operating via the steps you need. It saves the trouble I confronted with Selenium, the place you had been opening developer instruments and discovering the Xpath or comparable. Yuck ????

Now, to be trustworthy, there have been at all times instruments that might do that for you. However they had been both a) Not excellent b) Industrial and costly

The most effective half: Playwright “information” your steps and even offers you a operating Python script you may simply immediately use (or extract components from). I am critical in regards to the operating part- I can actually file a couple of steps and I’ll have a script I can then run with zero adjustments. The opposite instruments I attempted earlier than would provide you with small snippets of code that might sorta work, however probably not, forcing you to leap via hoops to get it working. Right here, you get a prepared made working script.

See Also

p

Playwright offers a reasonably good implementation that I discovered works more often than not. It solely sometimes missed a step, and in these instances I needed to manually add it to the script. However I discover Playwright’s ingredient discovery simpler than Selenium’s.

Different advantages: You possibly can file your runs as a video so you may view them later in case you discover any unusual failures. Playwright additionally creates an in depth hint you should use to type of “step via” any failed runs.

Cons? It is nonetheless new. Meaning bugs and not-as-good documentation. I discovered bizarre points (when utilizing the recorder) the place I could not scroll right down to the underside of the display in Playwright’s Chromium, however might in a traditional Chrome, forcing me to make use of different methods to click on the button. However I do not know if this was a Chromium or Playwright problem.

However general, for any new mission, I might at all times select Playwright over any present instruments.

Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top