முக்கிய உள்ளடக்கத்திற்கு தாவு

parentElement

தேர்ந்தெடுக்கப்பட்ட DOM-உறுப்பின் பெற்றோர் உறுப்பை திருப்பித் தருகிறது.

பயன்பாடு
$(selector).parentElement()
எடுத்துக்காட்டுகள்
index.html
<div class="parent">
<p>Sibling One</p>
<p>Sibling Two</p>
<p>Sibling Three</p>
</div>
parentElement.js
it('should get class from parent element', async () => {
const elem = await $$('p');
const parent = await elem[2].parentElement()
console.log(await parent.getAttribute('class')); // outputs: "parent"
});
திருப்பி அனுப்புகிறது
  • <WebdriverIO.Element>

Welcome! How can I help?

WebdriverIO AI Copilot