Playwright vs Selenium

Profile picture for user arilio666

Today, we will discuss two open-source tools, Playwright from Microsoft, the newest addition to Automation Framework. And another one is the most preferred tool, Selenium, which has been with us for more than a decade now. 

CriteriaPlaywrightSelenium
Browser SupportPlaywright supports three browser engines: Chromium, Firefox, and WebKit. Chromium includes the browsers Opera, Chrome, and Edge. Gecko Driver supports Firefox and Webkit is behind Apple Safari.Selenium has the support of Chrome, Firefox, Opera, Edge, and IE. Selenium has the extra browser support IE, whereas Microsoft abandoned this in playwright.
Supported LanguagesPlaywright supports Java, Python, .Net C# and JavaScript.Selenium supports all languages supported by Playwright like Java, Python, .Net C#, and JavaScript, and it has support for three additional languages, including RubyPHP, and Perl.
Handling Web ElementsThe Playwright's philosophy and technique of handling alerts, iframe, and elements are different than Selenium.Selenium has different WebDriver protocols and architecture to handle DOM elements.
AssertionsPlaywright uses Expect library from JEST for assertions.Selenium uses third-party libraries like Hamcrest, TestNG, and JUnit.
Test FrameworkThe Playwright supports Mocha, Jest, Jasmine, and AVA.Selenium supports Mocha, Jest, Jasmine, WebDriver IO, Protractor, TestNG, JUnit, and NUnit.
ArchitecturePlaywright has a Headless browser with event-driven architecture.Selenium has layers architecture based on JSON wire protocol.
Community SupportThe Playwright is new to the field, and community support is pretty limited compared to Selenium.Selenium provides unlimited support for its users via theSelenium ecosystem and self-support documents.
Real DevicesThe Playwright has experimental support for devices but supports emulators.Selenium supports real device clouds and remote servers.
PrerequisitesNeed NodeJS to be in fully functional mode.Selenium requires a standalone selenium server or Client Language Bindings, and browser drivers.
OS SupportYou can execute your Playwright test on Windows, Linux, and Mac platforms.Apart from Windows, Linux, and Mac, Selenium supports Solaris.
Auto WaitsThe Playwright does various actionability checks on elements before performing specific actions, which makes the execution of the tests much more stable.In Selenium, we use different types of waits, like implicit and explicit waits..
Speed of Script ExecutionScript execution in Playwright is faster compared to Selenium. Playwright uses a WebSocket connection rather than the WebDriver API and HTTP. This stays open for the duration of the test, so everything is sent on one connection. This is one reason why Playwright’s execution speeds tend to be faster.Selenium is comparatively slower because the driver serves as a middleman who translates the test script commands and sends them to the browser for execution.

Conclusion

Selenium is a well-established tool with great community and Language Support. On the other hand, Playwright is a new tool with less documentation which is comparatively faster and suitable for complex JavaScript applications. The Playwright is coming up with many features, but it is too early to say that it is an alternative to Selenium.