Error while interacting with Web element on runtime

Symptom

A Web automation action (like "Click Link", "Populate text field" or "Get details of element" etc.) fails during runtime.  

Verifying issue

During the initial development of the desktop flow, the user was able to capture and interact with the web element. 

Cause

Some web pages change their underlying HTML structure dynamically. Therefore, the CSS selector initially used to locate the element is no longer applicable. 

Resolution

Manually create a new more robust CSS selector, that will be able to locate the element of interest even though the HTML structure changes. 

To achieve that, capture again the web element after the failure, and compare the new CSS selector with the old one. 

CSS selectors can be reviewed and edited through the Selector builder window: 

PAD Selector builder window

Notice the differences between the two selectors – there may be one or more elements/attributes that are different. 

Edit the selector to contain only the static parts that are not prone to change. Some of the below methods could be followed: 

  1. Remove any dynamic values like numbers and modify the relevant Operators accordingly (Starts with, Ends with, Contains etc.) 

  2. Remove an entire element from the selector path if necessary 

  3. Locate the element using its text that is visible on the webpage using the “Contains” selector 

  

Examples 

  1. The selector contains an element with a class that is dynamic, like div[class=”some_class123”]. This can be modified to div[class^=”some_class”] ("Starts with" operator) 

  2. The selector contains an element with many dynamic attributes like div[class=”some_class123”][id=”some_id123”] > a[id=”some_id”]. This can be modified to a[id=”some_id”] (omitting the first part completely) 

  3. The element of interest has some static text - the selector can be modified to include only that text. For example, div[class=”some_class123”][id=”some_id123”] > a[id=”some_id”] could be modified to a:contains(“the_text_we_see_on_the_webpage”) 

Need more help?

Expand your skills
Explore Training
Get new features first
Join Microsoft Insiders

Was this information helpful?

Thank you for your feedback!

Thank you for your feedback! It sounds like it might be helpful to connect you to one of our Office support agents.

×