I used webdriverIO library in my programming. Recently I upgraded from version 4 to version 5. To my horror so many breaking changes and not much explanation on the internet. So I put some difference on it.
WebDriveIO – Version 4
const options = { desiredCapabilities: { browserName: 'firefox' } }; const browser = webdriverio.remote(options); await browser.init(); const select = "a"; const attribute = "href"; let results = await browser.getAttribute(selector, attribute); results = await browser.getHTML(selector);
WebDriverIO – Version 5
const options = { capabilities: { browserName: 'firefox' } }; const browser = await webdriverio.remote(options); const select = "a"; const attribute = "href"; let elements = await browser.$(selector); let results = await elements.getAttribute(attribute); elements = await browser.$(selector); results = await elements.getHTML(selector);
The Difference
- In version 5, options desiredCapabilities change to capabilities
- In version 5, need to put await in remote and no need to declare init() anymore as it is deprecated.
- In version 5, use $(selector) to select elements before getting elements content or attribute.