मुख्य सामग्री पर जाएं

कस्टम$

custom$ आपको browser.addLocatorStrategy का उपयोग करके घोषित एक कस्टम रणनीति का उपयोग करने की अनुमति देता है। कस्टम सेलेक्टर रणनीतियों के बारे में अधिक जानकारी सेलेक्टर दस्तावेज़ में पढ़ें।

उपयोग
$(selector).custom$(strategyName, strategyArguments)
पैरामीटर्स
नामप्रकारविवरण
strategyNamestring
strategyArguments*
उदाहरण
customStrategy.js
loading...
example.html
loading...
customStrategy.js
loading...
example.js
it('should fetch the project title', async () => {
await browser.url('https://webdriver.io')
await browser.addLocatorStrategy('myStrat', (selector) => {
return document.querySelectorAll(selector)
})

const header = await browser.custom$('myStrat', 'header')
const projectTitle = await header.custom$('myStrat', '.projectTitle')

console.log(projectTitle.getText()) // WEBDRIVER I/O
})
रिटर्न
  • <WebdriverIO.Element>

Welcome! How can I help?

WebdriverIO AI Copilot