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
2
Answers
You must do this manually because WDIO (Selenium) has a different code style. Only Puppeteer is more-less looks the same.
Check https://playwright.dev/docs/protractor, since it’s more close wdio.
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.
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.
I hope it helps.