Next-Generation Browser Automation With Playwright and Robocorp
Modern browser automation with Robocorp and Playwright-based Robot Framework Browser is here!
April 19, 2021
Automating a web browser to complete web-based workflows; How hard can it be? Just use Selenium, right? It contains everything and the kitchen sink! 🕸
Robocorp has and will continue to have full support for Selenium. In many cases, it is the perfect choice for your web automation needs. Being the de facto default browser automation tool, Selenium can handle most, if not all, use cases you throw at it and has a ton of support available!
But Selenium is not the only option Robocorp supports! For the pioneers out there, we present you Playwright-based automation!
As with all technologies new’ish, things take time to stabilize. Robocorp’s Playwright-support already handles many scenarios well but is not a silver bullet that solves all your automation problems and brews your coffee! For the best stability and reliability, consider relying on the proven solution, Selenium. But definitely give the newcomer a try!
Next, let’s take a look at some of the common pain points with Selenium-based web automation!
Waiting for elements
We will need to log into the application. First, you need to get rid of that annoying popup blocking the login form. The popup appears after a random delay. Let’s tell Selenium to wait for it! ⏱
I wish Selenium would wait for things without me telling it all the time... 🤔
Ah, there it pops! Now, just click the “OK” button! 🐁
Have you seen my button, dear?
Element not found. Hmm. Based on the Selenium screenshot, the “OK” button is visible! It seems to exist inside an iframe element, so clicking it requires some more instructions. Let’s tell Selenium to switch to the iframe, navigate down the DOM, find the button, click the button, wait for the popup to go away, and switch back to the main window!
Click A Button With These 10 Simple Steps! 😅 But seriously, I wish Selenium would dive down the DOM and click the darned button without the need for all these commands!
Navigating the DOM is supposed to be hard, right?
Finally. Popup popped down (🥁)! Time to fill in those login credentials. Let’s target the form input elements and be done with it!
Why waste time use lot element when few element do trick? - Not Kevin Malone from The Office
I wish Selenium had more powerful selectors supporting combining XPath and CSS expressions in one line of magic!
Once upon a time, there was a browser version mismatch. Again.
Ok. Coding done. Time to run the thing for real!
WebDriver Does Not Like Your Version Of The Browser THX Bye. Ahh, crap... Need to update my browser. Again. 🤦♀️
I wish I would not have to deal with browsers and their drivers! 🤯
Dear Santa. All I wish for browser automation is...
- Automatic waiting for things without explicitly asking all the time.
- Diving into iframes and shadow DOM without effort.
- Combining the power of XPath and CSS selectors.
- Managing the browsers and their drivers automagically.
Maybe someday, somewhere, a solution supporting all those will become available. One can wish! 🤞
Today is your lucky day!
If you are one of the lucky ones using the open-source stack for simplifying automation by Robocorp, you are in for a treat! Robocorp supports the Robot Framework Browser library, based on Playwright, based on Puppeteer, based on the will to rid of mundane steps from browser automation!
Go and read our A new option for web automation: Using the Robot Framework Browser library, based on Playwright article to learn why web automation in 2021 and beyond will benefit from new innovations! Fear not; Selenium is here to stay, and as strong as ever. Robocorp will support all the best tools, now and in the future!
So. Which option should I use?
For most production use cases, Selenium is a great default choice! Selenium has been around for so long it has reached a good level of maturity. Robocorp’s Playwright-support is constantly improving. Playwright addresses many of Selenium’s common pain points nicely, so if you are ok with doing some experimenting and are not afraid of the occasional bump in the road, do give it a try. Both of the options are supported now and in the future!