Get HTML code for a page element

Element HTML commands

Usage

// get the outer HTML of an element
UI.getHTML(target)
UI.getOuterHTML(target)

// get the inner HTML of an element
UI.getInnerHTML(target)
ParameterTypeRemarks
targetstringExpression to target an element. This can be a text, CSS selector, or XPATH selector.

Example(s)

Let's use this example button for reference:

<button id="sign-up-button">
  <b>Create</b> an account
</button>

We can read the outer and inner HTML of the button in our test script like this:

var outerHTML = I.getHTML("sign-up-button")
// outerHTML includes the html of the element and its contents:
// <button id="sign-up-button"><b>Create</b> an account</button>

var innerHTML = I.getInnerHTML("sign-up-button")
// innerHTML includes the html of the element's contents only:
// <b>Create</b> an account
Last Updated: