Guidelines

1. When locating a Web Element using any of its attributes(id, title, name, type, placeholder, class, text e.t.c), we need to make sure that the attribute value is unique. For example, if there are two buttons with the name 'submit' on the same page, we cannot use that attribute.

2. In cases where no other unique Identifiers are present, we will make use of Xpath locators or CSS locators.


However, there can be a number of issues when using UI Identifiers for your Test Steps. Some of them are:

  • Problem 1 - Element not found
  • Problem 2 - Duplicate UI Identifiers
  • Problem 3 - Hidden or disabled Elements
  • Problem 4 - Incorrect/Invalid UI Identifiers
  • Problem 5 - Empty UI Identifiers
  • Problem 6 - Element not clickable/interactable
  • Problem 7 - Stale Element

Problem 1 - Element not found


There can be mainly three reasons for the error:


1. Element not present in current page

Cause: The Element is not present on the current page. One of the previous steps might have passed but not run as expected.

Solution: Check the screenshot of the previous steps to know where it failed and correct the Step there. Please feel free to contact Support on chat if you need more help.


2. UI Identifier value is incorrect

Cause: The UI Identifier might be incorrect and therefore Testsigma is not able to find an Element with the given UI Identifier. The above-given image is an example of this error. You can see there is a typo in the UI Identifier(xpath value) in this case.

Solution: Check and correct the UI Identifier value or use Testsigma Recorder. If the element was recorded using Testsigma Recorder, please feel free to contact the Support on chat to report the issue.


3. Element is located in an external frame

Cause: The Element is inside an Internal Frame rather than the Body of the HTML Document.

Solution: You need to switch to the Frame first where the element is located before interacting with the element using 'Click' or 'Type' Statements. You can use any of the following Grammar:

  • Switch to the frame ui identifier
  • Switch to the frame by index test data
  • Switch to the frame with name test data



Problem 2 - Duplicate UI Identifiers

In this case, the Test Step might not actually fail. The Test Step will pass and the execution will continue although the correct Element was not selected. This is undesirable.


Cause: As you can see above, we used the xpath //input[@type='password'] and there are two matching Elements as shown in the image for the same xpath. This is a case of duplicate UI Identifiers and even if we need to select the second field, the first Element with the corresponding UI Identifier will be selected always.

Solution: Use a different XPath that is unique for the element.


Problem 3 - Hidden or disabled Elements

Element is either hidden or disabled exception


1. Dynamic Elements not available at runtime

Cause: Sometimes, the element might be created dynamically and might not be present in the Web page at that instant.

Solution: Wait for the element to be present by adding a wait step.


2. Disabled or hidden Element

Cause: The given UI Identifier is hidden or disabled. Elements are sometimes hidden or disabled by the developer if they are not meant to be interacted with.

In the above image, you can see the type='hidden' for these input elements. An element may be hidden also using class names such as 'hide', 'hidden' or attributes(angular directives) such as 'ng-hide'.

Solution: If the element is hidden, the developer doesn't want the user to interact with it. Find another element that can be interacted upon.


Problem 4 - Incorrect/Invalid UI Identifiers

The element corresponding to the locator type "id_value" and locator "//*[@id='lgnjs']" is not displayed.

1. Mismatch between UI Identifier type and UI Identifier value

Cause: Check the selected locator type corresponds to locator value. Locator type is 'id' but the given locator value is in 'xpath' format.

Solution: Correct the locator value corresponding to the locator type.


2. Element is not displayed in page

Cause: We can rule out the mismatch of Locator Type and Locator value in the above message.

Solution: Check whether the element is actually displayed in the present page.



Problem 5 - Empty UI Identifiers

Empty locator value provided for the locator type "id_value".

Cause: No value provided for the UI Identifier.

Solution: Check the value of the UI Identifier and make sure that ui identifier value is not be empty.


Problem 6 - Element not clickable/interactable

Element not clickable at point (x,y). Other element would receive the click:



1. Another Element overlapping temporarily
Cause: The Element is covered or overlapped by another element temporarily(during a page load).

Solution: Add a wait step for the overlapping element to go away itself. The overlapping element will disappear automatically once the page loads completely.


2. Another Element overlapping until user acts upon it

Cause: The Element is covered or overlapped by another element that needs to be closed/removed (like sticky menus, drop down menus or alerts).

Solution: Add a Step to close/remove the overlapping Element. For Ad or Survey popups, there would be a close button which can be clicked to close the popup.


3. Element out of page view

Cause: The Element is not visible in the current Browser Window view. Check whether the Element is actually visible in the Test Step Screenshot(inside the Browser view port).

Solution: If the Element is not inside the view, add a Test Step to scroll to the Element.


Problem 7 - Stale Element Exception

The element corresponding to the locator type "X" and locator "Y" cannot be interacted with since it is no longer appears/exists on the DOM of the page.


1. The element is no longer attached to the DOM

Cause: The element you are trying to interact with might be a dynamically rendered element that detaches/reattaches itself to the DOM/ HTML Source dynamically after the page load is complete. This is the most common cause.

More info: Page Elements are detached from the HTML DOM during AJAX requests or Page reloads and reattach automatically once the function is executed.

Solution 1: Add a wait step so as to allow time for the element to be added to the DOM using the "Wait for test data seconds" template as shown here: How to add a Wait in Test Cases?

Solution 2: Add a Page Refresh step so that the element is loaded quickly on next reload.


2. The element has been removed from the DOM

Cause: The element has been deleted entirely.

Solution: Get the UI Identifier for the element once again.