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

previousElement

चयनित DOM-तत्व का पिछला सहोदर तत्व लौटाता है।

उपयोग
$(selector).previousElement()
उदाहरण
index.html
<div class="parent">
<p>Sibling One</p>
<p>Sibling Two</p>
<p>Sibling Three</p>
</div>
previousElement.js
it('should get text from previous sibling element', async () => {
const elem = await $$('p');
const previousElem = await elem[1].previousElement()
console.log(await previousElem.getText()); // outputs: "Sibling One"
});
रिटर्न्स
  • <WebdriverIO.Element>

Welcome! How can I help?

WebdriverIO AI Copilot