Selenium WebDriver vs. Playwright in a Nutshell
A quick comparison in the context of Web Test Automation
General
🍄 Selenium
🎭 Playwright
🍄 W3C WebDriver Standard
🎭 Not a W3C WebDriver Standard
🍄 Native support by all major browser vendors
🎭 No, downloads own browsers and does not include Chrome (has Chromium instead)
🍄 Established, first released in 2011, still active, the latest version 4.11 released three week ago (2023–07–31)
🎭 Released in 2020
🍄 Well-proven, used at Facebook and Google, was regarded the most popular web automation framework
🎭 It quickly overtook Cypress as the most popular web automation framework in the JS community.
🍄 Selenium is versatile, and works well for nearly all major programming languages. 5 official ones (Ruby, Python, Java, C# and JavaScript)
🎭 Playwright is limited to JavaScript, Python, Java and C#
🍄 Supports all major test syntax frameworks, such as RSpec, PyTest, JUnit and Mocha.
🎭 Playwright comes with its own test runner. In my opinion, it is less flexible.
Features/Limitations
Selenium is based on the W3C standard, so it is more feature complete and future proof.
Plawright does not work with Chrome (the client’s Chrome browser). Instead it installs it’s own Chromium version to use. Playwright guarantees functionality only for it’s downloaded browsers, and while executable paths can be defined to use client’s Chrome, it is generally not recommended.
Selenium can use the Ruby language, a long-time and proven good scripting language for Test Automation (since Watir, ~2003). According to the authors of the classic ‘Agile Testing Book’ (Lisa Crispin and Janet Gregory), Ruby is the best language for scripting automated tests — and I agree.
Also, “Ruby is the most in-demand skill”, according to Hired’s 2023 State of Software Engineers Report.
Playwright cannot clear text fields. It seems like a simple function to just clear a text-field. However, it does not currently exist in Playwright. Current solutions include: pressing backspace input value’s length number of times, triple clicking then deleting (source) or passing an empty string (documentation).
await page.evaluate( () => document.getElementById("inputID").value = "")
Playwright also has an auto test retry feature. If any test fails, Playwright will rerun the entire script file. I think this feature is unnecessary since it falls under the responsibility of the Continuous Testing Server rather than the automation framework.
Speed
A benchmark test running the AgileTravel login and flight tests.
Note that I ran the tests once first to warm up the test site and browser applications before I began recording the timing. Each combination was run 3 times each and approximate average is shown below.
On a Mac
Playwright with Mocha running on Chromium averaged 9 seconds.
Selenium with RSpec running on Chrome averaged 10.4 seconds.
Keep reading with a 7-day free trial
Subscribe to AgileWay’s Test Automation & Continuous Testing Blog to keep reading this post and get 7 days of free access to the full post archives.