Support & information center

Verify page content

Verify text

client.getText('#element', function(result) { // Remove whitespaces - recommended, as many times the text in the // web page includes whitespaces before and after the text var subResult = result.value.replace(/\s+/g, ''); var subExpected = expected_element.replace(/\s+/g, ''); client .info('Verify string (without whitespaces) result = %s, expected = %s', subResult, subExpected) .verify.equal(subResult, subExpected); })
Code language: JavaScript (javascript)

Do some actions if the element exists (without giving error)

client.element('param 1', 'param 2', function(visible) { if (visible.status !== null) { client.rtcInfo('element is visible'); } else { client.rtcInfo('element is NOT visible') } })
Code language: JavaScript (javascript)

param 1 – locator strategy. Can be one of the following values: class name, css selector, id, name, link text, partial link text, tag name, xpath

param 2 – locator to search for


Search for element by id:

.element('id', 'user_email_id', function(visible)
Code language: JavaScript (javascript)

Search for element by class name:

.element('class name', 'user_email_class', function(visible)
Code language: JavaScript (javascript)

Was this article helpful?

Related Articles