javascriptconvertersplaywrightwebdriver-iotestautomationfx

webdriverIO Framework Migration to Playwright


I am trying to convert webdriverIO scripts to playwright scripts. Both are in JavaScript. I’d like to know if anyone of you have converted this type of project and is there any converter projects you encountered?

I already started manually translating to playwright. I’m looking for a quick way if possible


Solution

  • No and yes.

    No - Atleast I am not aware of anything like which automatically converts it for you.

    Yes - you can reuse lot of code with right strategy.

    Who am I? - I am someone who have migrated an large (5000+ tests) framework from Protractor to playwright successfully recently.

    Here are my lessons learnt:

    Language:

    This is the most important thing. As long as new and old framework implemented in JavaScript or TypeScript , we are basically overall in the same ecosystem.

    NodeJS:

    As long as new and old framework are living in nodejs ecosystem, all the external node modules used can be re-used mostly as is.

    Test Scripts:

    As long you are using any standard test framework( Mocha/Jasmine/Jest) for your tests scripting you can almost use it as is - no change if you are only calling page object methods in scripts so your actual code is hidden & encapsulated in your page objects as it should be.

    Objects Locators( Css/Xpath):

    No matter which framework/ library/ language/ tool you use they will be same and can be used as is as they are independent.

    Page Object Methods:

    This is the place where most changes may happen and even that can be avoided up to an extent if you have implemented custom wrapper functions over library functions to hide the implementation details.

    Utility/Supporter functions

    Again this depends upon how elegantly and cleanly code has been abstracted out in multiple layers to minimize the change in lowest layers only without touching any higher layers.

    Test Data:

    Again with right strategy it can also be kept totally isolated from the framework in the form of Json/xml/csv/text data and can be fed in test scripts as needed. As long it is implemented correctly, most of it can be re- used as is.

    Configuration:

    It's not a biggie as it's one time and not much code to change.

    The key take away from this is - design your framework with modular approach from beginning and abstract it out in multiple layers in such a way that each component/ class is only loosely coupled with each other so that any piece can be replaced/ updated easily without affecting the whole system.

    I hope it helps.

    For Further Reading:

    https://playwright.dev/docs/protractor

    https://playwright.dev/docs/puppeteer

    https://playwright.dev/docs/testing-library