Skip to main content

call

Overview

Use the call command to perform any asynchronous action in tests.

This command is treated as a synchronous function. It accepts a promise and halts its execution until the promise is resolved.

Usage

await browser.call(callback);

Command Parameters

NameTypeDescription
callbackFunctionThe function to call.

Usage Examples

it("some testing here", async ({ browser }) => {
await browser.url("http://google.com");

// make an asynchronous call using a third-party library
// that supports promises, e.g., a call to a backend or DB
// to inject a fixture
await browser.call(() => {
return somePromiseLibrary.someMethod().then(() => {
// ...
});
});

// example for an asynchronous call using a third-party library
// that does not support promises
const result = await browser.call(() => {
return new Promise((resolve, reject) => {
someOtherNodeLibrary.someMethod(param1, (err, res) => {
if (err) {
return reject(err);
}
resolve(res);
});
});
});
});

References

We'd like to give credit to the original WebdriverIO docs article, from which we drew some information while writing our version.