call
Mit call
können Sie jede asynchrone Aktion innerhalb Ihrer Test-Spezifikation ausführen.
Es akzeptiert Promises und hält die Ausführung an, bis das Promise aufgelöst wurde.
Info
Da WebdriverIO die synchrone Verwendung auslaufen lässt (siehe RFC), ist dieser Befehl nicht mehr sehr nützlich.
Verwendung
browser.call(callback)
Parameter
Name | Type | Details |
---|---|---|
callback | Function | Funktion, die aufgerufen werden soll |
Beispiel
call.js
it('some testing here', async () => {
await browser.url('http://google.com')
// make an asynchronous call using any 3rd party library supporting promises
// e.g. call to backend or db to inject fixture data
await browser.call(() => {
return somePromiseLibrary.someMethod().then(() => {
// ...
})
})
// example for async call to 3rd party library that doesn't support promises
const result = await browser.call(() => {
return new Promise((resolve, reject) => {
someOtherNodeLibrary.someMethod(param1, (err, res) => {
if (err) {
return reject(err)
}
resolve(res)
})
})
})
});