call
Vous pouvez utiliser call
pour exécuter n'importe quelle action asynchrone dans votre test spec.
Il accepte les promesses et arrête l'exécution jusqu'à ce que la promesse soit résolue.
info
Avec WebdriverIO dépréciant l'utilisation synchrone (voir RFC) cette commande n'est plus très utile.
Utilisation
browser.call(callback)
Paramètres
Nom | Type | Détails |
---|---|---|
callback | Function | fonction à appeler |
Exemple
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)
})
})
})
});