addCommand
உலாவி முறை addCommand
உங்கள் சொந்த கட்டளைகளை எழுத உதவுகிறது.
தகவல்
கஸ்டம் கட்டளைகளைச் சேர்ப்பது குறித்த மேலும் தகவல்களை கஸ்டம் கட்டளை வழிகாட்டியில் காணலாம்.
பயன்பாடு
browser.addCommand(name, callback, elementScope)
அளவுருக்கள்
பெயர் | வகை | விவரங்கள் |
---|---|---|
name | string | கஸ்டம் கட்டளையின் பெயர் |
callback | Function | அழைக்கப்பட வேண்டிய செயல்பாடு |
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')
})