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
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:
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.
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.
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.
No matter which framework/ library/ language/ tool you use they will be same and can be used as is as they are independent.
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.
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.
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.
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