முக்கிய உள்ளடக்கத்திற்குச் செல்லவும்

getAttribute பெறு

பண்புக்கூறு பெயரின் அடிப்படையில் DOM-உறுப்பிலிருந்து ஒரு பண்புக்கூறை பெறவும்.

பயன்பாடு
$(selector).getAttribute(attributeName)
அளவுருக்கள்
பெயர்வகைவிவரங்கள்
attributeNamestringகோரப்பட்ட பண்புக்கூறு
எடுத்துக்காட்டுகள்
index.html
<form action="/submit" method="post" class="loginForm">
<input type="text" name="name" placeholder="username"></input>
<input type="text" name="password" placeholder="password"></input>
<input type="submit" name="submit" value="submit"></input>
</form>
getAttribute.js
it('should demonstrate the getAttribute command', async () => {
const form = await $('form')
const attr = await form.getAttribute('method')
console.log(attr) // outputs: "post"
})
திரும்பப் பெறுகிறது
  • <String|null> return: பண்புக்கூறின் மதிப்பு, அல்லது அது உறுப்பில் அமைக்கப்படாவிட்டால் null.

Welcome! How can I help?

WebdriverIO AI Copilot
OSZAR »