Skip to content

UI.getOuterHTML()

Gets the outer HTML of an element.

This returns the full HTML of the element, including the element’s own tag and all of its child content.

Usage

js
var html = UI.getOuterHTML(element: string)

Parameters

ParameterTypeDescription
elementstringTarget element — by CSS or XPath selector

Returns

Returns the outer HTML of the element as a string.

Example

js
var html = UI.getOuterHTML("#checkout-form")

var hasErrorClass = /class=["'][^"']*\bhas-error\b[^"']*["']/
if (!hasErrorClass.test(html)) {
    TEST.log.fail("Expected checkout form to have 'has-error' CSS class")
}

In this example, the test retrieves the outer HTML of #checkout-form and checks that the "has-error" CSS class appears within the element’s markup, indicating that the form (or one of its child elements) is in an error state.