Skip to content

UI.getInnerHTML()

Gets the inner HTML of an element.

This returns the raw HTML content inside the element, excluding the element’s own tag.

Usage

javascript
var html = UI.getInnerHTML(element: string)

Parameters

ParameterTypeDescription
elementstringTarget element — by CSS or XPath selector

Returns

Returns the inner HTML of the element as a string.

Example

js
var html = UI.getInnerHTML(".alert-message")

if (!html.includes("Out of stock")) {
    TEST.log.fail("Expected 'Out of stock' message was not found")
}

This example retrieves the inner HTML of the .alert-message element and checks that it contains the text "Out of stock".