We're starting to write E2E tests using Playwright in Typescript. Up until now, we were using Selenium and we wrote an a abstracation layer, or a a client, that wrapped each Selenium function that were used by our E2E test. You could see, in a simple search in Google, many different clients that different people have written to Selenium API. However, I didn't find even a single client for Playwright and I wonder whether we should implement it or not? Maybe it's because that Playwright already provides a high-level API that is designed to be easy to use and understand.
Our main reasons for that are:
- Improved reliability and Stability: Because Playwright wrappers can provide additional functionality, they can help to improve the reliability of automated tests. By making it easier to write tests that are less likely to fail, Playwright wrappers can help to ensure that tests provide accurate and consistent results. i.e.: By using the Playwright function
def fill(text: str), we can type a text into a text field. If we write a wrapper for this function that also waits, by default, until the text is displayed, we’ll get more stable results. For that matter, Playwright provides async matches that will wait until the expected condition is met. Playwright encourages to do so, as specified in their documentation:these matchers allows making the tests non-flaky and resilient - Decoupling from Playwright's API: By using a client for Playwright, our test code interacts with the client’s API rather than directly with Playwright's API. If Playwright undergoes significant changes or introduces breaking updates, we’ll only need to update the wrapper to adapt to those changes. The rest of our test code remains unaffected, reducing the effort required to maintain your automation suite. i.e: Selenium introduced many breaking changes in version 4.0 in different functions and components. Luckily, since we’re using a client that is wrapping Selenium API, the test code remained unaffected and we only needed to update the client.
- Error Handling and Reporting: A wrapper can implement consistent error handling strategies and provide meaningful error messages when exceptions occur
And therefore, my question, would you recommened to write an abtraction layer over Playwright?
I've tried to find an implementation of an abtraction layer for Playwright in Google but didn't find anything.