Aller au contenu principal

overwriteCommand

La méthode du navigateur overwriteCommand vous aide à remplacer les commandes natives du navigateur et de l'élément comme pause et click.

info

Vous pouvez consulter plus d'informations à ce sujet dans la section commande personnalisée.

Utilisation​
browser.overwriteCommand(name, callback, elementScope)
Paramètres​
NomTypeDétails
namestringnom de la commande originale
callbackFunctionpasse la fonction originale
elementScope
optionnel
Booleanétendre l'objet Element au lieu de l'objet Browser
Exemple​
execute.js
// print milliseconds before pause and return its value.
await browser.overwriteCommand('pause', function (origPauseFunction, ms) {
console.log(`Sleeping for ${ms}`)
origPauseFunction(ms)
return ms
})

// usage
it('should use my overwrite command', async () => {
await browser.url('https://webdriver.io')
await browser.pause(1000) // outputs "Sleeping for 1000"
})

Welcome! How can I help?

WebdriverIO AI Copilot