call
Puoi utilizzare call
per eseguire qualsiasi azione asincrona all'interno della tua specifica di test.
Accetta promesse e ferma l'esecuzione fino a quando la promessa non è stata risolta.
informazione
Con WebdriverIO che depreca l'uso sincrono (vedi RFC) questo comando non è più molto utile.
Utilizzo
browser.call(callback)
Parametri
Nome | Tipo | Dettagli |
---|---|---|
callback | Function | funzione da chiamare |
Esempio
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)
})
})
})
});