Knowledge Base

  1. Home
  2. Knowledge Base
  3. General
  4. How-to
  5. 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);
})

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

.element('param 1', 'param 2', function(visible) {
   if(visible.status !== -1){
     client.rtcInfo('element is visible');
   } else {
     client.rtcInfo('element is NOT visible')
   }
})

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

Examples:

Search for element by id:

.element('id', 'user_email_id', function(visible)

Search for element by class name:

.element('class name', 'user_email_class', function(visible)

 

Was this article helpful?

Related Articles

Leave a Reply 0 comments

Leave a Reply: