Trying out WebdriverIO 6
During last March it was announced the release of WebdriverIO v6. Here are some of the new features and enhancements that I found.
Assertion library out of the box
In previous versions you needed to add an assertion library such as chaijs to perform the usual
expect(actualValue).to.equal(expectedValue, 'I am the error message');
Now webdriverio comes with its own assertion library that is made on top of jest expect and it have some steroids. e.g.:
Before
const actualText = myWebElement.getText();
expect(actualText).to.equal(expectedText, 'Text does not match expected');
After
expect(myWebElement).toHaveText(expectedText, { message: 'Text does not match expected' });
Did you note the object param in the toHaveText function? It has to be with another new feature on v6.
Named Parameters
It was a bit uncomfortable to add null on some functions to get to a given parameter, e.g.:
// Waits for myWebElement to NOT exist
myWebElement.waitForExist(null, null, true);
But fortunately it was improved to:
// Waits for myWebElement to NOT exist
myWebElement.waitForExist({ reverse: true });
New services defintion
On a similar approach the services configuration are now in the same list as the service defintion, e.g.:
// wdio.conf.js
exports.config = {
// ...
service: [
['sauce', {
sauceConnect: true, // @wdio/sauce-service configuration
sauceConnectOpts: {
//...
} // @wdio/sauce-service configuration
}]
],
// ...
};
Thos are just three examples of the new features on v6, check the official release notes for more details.