PlayWright – yes please!

·

·

What is PlayWright, Selenium, etc?

In short: PlayWright and Selenium is browser testing tools. Using these tools we can use a few lines of code to automate an entire browser. This is great news for someone in testing since we’re often working with various applications and services that has a webbased GUI.

So how can we use these tools?

  • Click various buttons and create a report.
  • Execute longer user flows. Like logging in, placing an order, logging out and generating a report.
  • Check if a website is online.
  • Check if there’s an error somewhere.
  • Anything else you can think of that you can do in a browser.

Why should you try PlayWright?

Using PlayWright and Python we can design complex automated testcases that previously would’ve taken 300% longer to create.

After spending lots of hours with Selenium with all the wacky-selectors and associated problems I’ve found PlayWright a blessing.

So imagine we have this button:

To create this button we mix some HTML together:

<button id="button" type="button" class="btn btn-primary">Hello Mister Button</button>

Now we can’t to click this button using Selenium, we would have to do something like this:

button = driver.find_element_by_id('button')
button.click()

But using PlayWright we can do something like this:

page.click("text='Hello Mister Button'")

Or of course, something like this:

page.click("id=button")

While this may seem trivial, imagine having tests consisting of thousands of lines of code. You can quickly see how it becomes very messy and cluttered with Selenium while when using PlayWright we can keep the code very tidy and organised.

Not only that, but PlayWright is so simple that you don’t actually really need a technical or coding background to understand what’s going on. Almost everyone would grasp that the code clicks the button with the text “Hello Mister Button” just by glancing at that code. This enables us to get help from various stakeholders within the organisation that may not neccessarily know anything about coding but might know a lot about the actual user flows that we are trying to emulate.

How am I using PlayWright?

Right now we have various PlayWright-based applications running. The most significant one might be the one called JAT.

What does JAT do?

Every day at 7 AM JAT creates user accounts in all the different countries where we are located, after verifying that this was possible JAT logs in into every account, places an order and verifies that the order was placed correctly and that everything looks OK.

This is a basic health check conducted every day that adds tremendous value. If JAT cannot create accounts or orders than the entire business model this company runs off is threatened. The CORE business that we do is offer stores and a online webstore where customers are able to place orders.



Leave a Reply

Your email address will not be published. Required fields are marked *