View Source Improve this doc

getHTML

Get source code of specified DOM element by selector.

Usage

1
browser.getHTML(selector[,includeSelectorTag]);

Parameters

Param Type Details
selector String element to get the current DOM structure from
includeSelectorTag
optional
Boolean if true it includes the selector element tag (default: true)

Example

index.html
1
2
3
<div id="test">
<span>Lorem ipsum dolor amet</span>
</div>
getHTML.js
1
2
3
4
5
6
7
8
9
10
11
it('should get html for certain elements', function () {
var outerHTML = browser.getHTML('#test');
console.log(outerHTML);
// outputs:
// "<div id="test"><span>Lorem ipsum dolor amet</span></div>"

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

Uses