முக்கிய உள்ளடக்கத்திற்குச் செல்லவும்

addCommand

உலாவி முறை addCommand உங்கள் சொந்த கட்டளைகளை எழுத உதவுகிறது.

தகவல்

கஸ்டம் கட்டளைகளைச் சேர்ப்பது குறித்த மேலும் தகவல்களை கஸ்டம் கட்டளை வழிகாட்டியில் காணலாம்.

பயன்பாடு​
browser.addCommand(name, callback, elementScope)
அளவுருக்கள்​
பெயர்வகைவிவரங்கள்
namestringகஸ்டம் கட்டளையின் பெயர்
callbackFunctionஅழைக்கப்பட வேண்டிய செயல்பாடு
elementScope
optional
Booleanஉலாவி பொருளுக்குப் பதிலாக Element பொருளை விரிவுபடுத்தவும்
உதாரணம்​
execute.js
await browser.addCommand('getUrlAndTitle', async function (customParam) {
// `this` refers to the `browser` scope
return {
url: await this.getUrl(),
title: await this.getTitle(),
customParam: customParam
}
})
//usage
it('should use my add command', async () => {
await browser.url('https://webdriver.io')
const result = await browser.getUrlAndTitle('foobar')

assert.strictEqual(result.url, 'https://webdriver.io')
assert.strictEqual(result.title, 'WebdriverIO · Next-gen browser and mobile automation test framework for Node.js | WebdriverIO')
assert.strictEqual(result.customParam, 'foobar')
})

Welcome! How can I help?

WebdriverIO AI Copilot