Skip to main content
🇺🇦  We stand with the people of Ukraine. We encourage compassion, and hope for peace.   🇺🇦
Please support humanitarian efforts for the Ukraine crisis through the International Committee of the Red Cross! #StandWithUkraine

overwriteCommand

The browser method overwriteCommand helps you to overwrite the browser's and element's native commands like pause and click.

info

You can view more information on this in the custom command section.

Usage
browser.overwriteCommand(name, callback, elementScope)
Parameters
NameTypeDetails
namestringname of the original command
callbackFunctionpass original function
elementScope
optional
Booleanextend the Element object instead of the Browser object
Example
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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.