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

getHTML

Get source code of specified DOM element by selector.

Usage
$(selector).getHTML(includeSelectorTag)
Parameters
NameTypeDetails
includeSelectorTag
optional
Booleanif true it includes the selector element tag (default: true)
Examples
index.html
<div id="test">
<span>Lorem ipsum dolor amet</span>
</div>
getHTML.js
it('should get html for certain elements', async () => {
var outerHTML = await $('#test').getHTML();
console.log(outerHTML);
// outputs:
// "<div id="test"><span>Lorem ipsum dolor amet</span></div>"

var innerHTML = await $('#test').getHTML(false);
console.log(innerHTML);
// outputs:
// "<span>Lorem ipsum dolor amet</span>"
});

Welcome! How can I help?

WebdriverIO AI Copilot