NLP locators are a set of locators that are defined in the NLP Statement itself. Examples for available NLP locators in Testsigma are:

  1. Title

  2. Placeholder

  3. Label

  4. Index

  5. Text

1. Title (type : Attribute)

The title HTML attribute specifies extra information about an element. The information is most often shown as a tooltip text when the mouse moves over the element.


Example HTML Code:

<p><abbr title="World Health Organization">WHO</abbr> was founded in 1948.</p>
<p title="Free Web tutorials">W3Schools.com</p>


Usable NLP statements

One of the NLP Statements with title NLP locator we can use for the above code is:

Click on the element with title World Health Organization


Most common Issues

For elements without the title attribute, the above template won't work and would throw an error. Therefore, please check the HTML by inspecting the element and confirm that the title attribute is present.


Solution

The soluton would be to use another locator such as CSS Selector, ID, XPath e.t.c or use the Testsigma Chrome recorder.


2. Placeholder (type: Attribute)

The placeholder HTML attribute specifies a short hint that describes the expected value of a input field / textarea. The short hint is displayed in the field before the user enters a value.

It is used for <input> and <textarea> HTML Elements.


Example HTML Code:

<input type="text" name="fname" placeholder="First name"><br>
<input type="text" name="lname" placeholder="Last name"><br>


Usable NLP Statements

Some of the NLP Statements with placeholder NLP locator that can be used for the above code is:

Enter test data in the element with placeholder attribute
Type test data in the element with placeholder attribute
Wait until a text box with placeholder test data is displayed
...


Most common Issues

Sometimes the placeholder in an input field would be given as simple text that you need to clear first and then enter the value. We cannot use the placeholder attribute to locate these elements.


Solution:

The soluton would be to use another locator such as CSS Selector, ID, XPath e.t.c or use the Testsigma Chrome recorder.


3. Label (type: Tag)

The <label> HTML tag defines a label for a <button>, <input>, <meter>, <output>, <progress>, <select>, or <textarea> element. The for attribute of the <label> tag should be equal to the id attribute of the related element to bind them together.


A label can be bound to an element either by using the "for" attribute, or by placing the element inside the <label> element.


Example HTML Code:

<label for="male">Male</label>
<input type="radio" name="gender" id="male" value="male">


Usable NLP Statements

One of the NLP Statements with Label NLP Locator we can use for the above code is:

Check the radio button with label test data


Most Common Issues

Sometimes, the label text for a <button>, <input>, <meter>, <output>, <progress>, <select>, or <textarea> element is not set using a label tag and it uses a simple inline text tag such as <span>, <div> or <p>. In such cases, the following templates and the likes of it won't work:


Solution

The soluton would be to use another locator such as CSS Selector, ID, XPath e.t.c or use the Testsigma Chrome recorder.


4. Index (type: Selector)

The index selector is used to select an item from a set of similar items using its position or index.


Example HTML Code:

  <select aria-label="Month" name="birthday_month" id="month" title="Month" class="_5dba"
  data-cip-id="jQuery342845640">
    <option value="0">      Month    </option>
    <option value="1">      Jan    </option>
    <option value="2">      Feb    </option>
    <option value="3" selected="1">      Mar    </option>
    <option value="4">      Apr    </option>
    <option value="5">      May    </option>
    <option value="6">      Jun    </option>
    <option value="7">      Jul    </option>
    <option value="8">      Aug    </option>
    <option value="9">      Sept    </option>
    <option value="10">      Oct    </option>
    <option value="11">      Nov    </option>
    <option value="12">      Dec    </option>
  </select>


Usable NLP Statements:

One of the NLP Statements with Index NLP Locator we can use for the above code is:

Select option by index test data in the ui identifier list


Most Common Issues:

The index starts with 1 and not 0. This might cause some issue.


Solution:

Use the correct index starting from 1.


5. Text

Please check the below document for more details:

Most common causes for Text Verification Errors in Testsigma - Verify, Click, Wait for, or Scroll to Element