Element-Not-Found issues
Here are some tips for resolving Element-Not-Found issues when using Locator-free element identification:
Handling Dynamic Labels
Label values can sometimes be dynamic, containing portions of text that change between use cases or follow certain patterns. In such cases, you can use operators like equals (ignoring case), starts with, ends with, contains, or matches regex to effectively handle dynamic labels. This ensures stability in your automation scripts, even when labels change dynamically.
Example: Consider a button with a dynamically changing label due to localized versions, such as "Submit Order" or "Submit Purchase." By utilizing the "starts with" operator, you can consistently interact with the button regardless of its specific localization. For instance, "Label starts with 'Submit.'"
Regular Expression Example
Regular expressions can also be useful in various situations. For instance, if you have a link displaying an 8-letter uppercase alphanumeric Transaction ID like "U9081AXZ," you can use a regular expression [A-Z0-9]{8} to click this link.
Data-Driven Labels
In some scenarios, the label value may be entirely data-driven, depending on the inputs used in the test case. ACCELQ enables you to use a Local Parameter, Action Parameter, or Global Property as the label for Locator-free Element identification.
For example, if you have a username link in the Profile section of a page, and there's already a parameter available with the user's First Name value, you can directly use it as the Label for element identification.
Statement using the Action Input parameter (User First Name)
Dynamic Anchor Text
Similar to dynamic labels, there may be situations where the anchor text is dynamic. ACCELQ allows you to apply the same operators, such as starts with, ends with, regex, etc., for handling dynamic anchor text. In addition, you can use variables/parameters for the anchor text value.
Multi-Match Elements
When utilizing a Locator-free approach for element identification, if multiple matching elements appear on the screen, several choices are available to ensure uniqueness. These options are discussed below in order of preference:
1. Using Anchor Text
One effective method is to locate a functionally meaningful text that is positioned above or to the left of the given label. By doing so, the search for the label becomes limited to the area under the designated anchor text, rather than the entire page.
This approach generally yields positive outcomes. Here are some tips for setting up anchor text:
- Ensure that you utilize only functionally relevant and meaningful text as anchor text. This text should remain consistent across various use cases within the application.
- Consider using operators like starts-with, ends-with, contains, regex, etc., to account for any variable portions of the anchor text.
Setting up Anchor Text
In the Logic Editor, you can select the option to provide anchor text and type the value along with the operator.
When working with Element troubleshooting, you have the option to choose from the modal as displayed below.
2. Using Index for Differentiation
Another technique involves utilizing an index to indicate a specific element among multiple matches. The index is based on the physical location of the element on the screen, typically ordered from the upper left corner of the screen. If the anchor-text method fails, the index can be used to reference a particular instance using a numerical value.
This approach is especially valuable when dealing with repeated instances of the same element on the screen, where the number of instances itself is dynamic. A common scenario might involve "Select" buttons appearing alongside each displayed flight result in a travel application.
When implementing the Index method, you can provide a relative number starting from either the top or the bottom of the screen. For instance, you might refer to the "2nd Select button from the bottom."
Setting up Index
When typing the statement in the logic editor, you can suffix the index number after the label specification using a "#n" notation. You can specify the index from the bottom of the screen by using a negative number.
When working with Element troubleshooting, you have the option to choose from the modal as displayed below.
Note: You can also utilize the Index in conjunction with anchor text. When using anchor text, only the content of the page below or to the right of the anchor text is taken into account. Consequently, the Index calculation will also commence from that specific location on the page. So, be sure to calculate the Index value accordingly.
Comments
0 comments
Please sign in to leave a comment.