Przejdź do głównej treści

nextElement

Zwraca następny element rodzeństwa (sibling) wybranego elementu DOM.

Użycie
$(selector).nextElement()
Przykłady
index.html
<div class="parent">
<p>Sibling One</p>
<p>Sibling Two</p>
<p>Sibling Three</p>
</div>
nextElement.js
it('should get text from next sibling element', async () => {
const elem = await $$('p');
const nextElement = await elem[1].nextElement()
console.log(await nextElement.getText()); // outputs: "Sibling Three"
});
Zwraca
  • <WebdriverIO.Element>

Welcome! How can I help?

WebdriverIO AI Copilot