Question

Recorder fails to find object due to dynamic DOMXPath / Path

  • 7 December 2022
  • 4 replies
  • 272 views

Badge +3

Can wildcards be used in objects that slightly change?

The object is really just a folder in a web portal, the problem is when a new folder is added, the path changes. Any suggestions would be helpful. 

See below comparison of domxpath differences and picture of object

 

Old DOMXPath: 

//div[@id='teamFoldersSlideoutContent']/div[3]/div[1]/div[1]/div[1]/table[1]/tbody[1]/tr[4]/td[2]/div[1]/div[1]

NewDOMXPATH:

//div[@id='teamFoldersSlideoutContent']/div[3]/div[1]/div[1]/div[1]/table[1]/tbody[1]/tr[5]/td[2]/div[1]/div[1]

 


 


4 replies

Badge +3

Hey @EricSullivan ,

 

As per the path shared I can see that it is a table, and as you want to capture the last item what you can do is capture the table and get the number of rows and pass that variable in the tr[] as because only the tr is changing rest everything is same.

 

Userlevel 7
Badge +10

Hi @EricSullivan ,

 

You can keep a counter as mentioned below and increment the same while looping through each row of that table.

 

//div[@id='teamFoldersSlideoutContent']/div[3]/div[1]/div[1]/div[1]/table[1]/tbody[1]/tr[$Counter$]/td[2]/div[1]/div[1]

 

Keep in mind that the Counter variable has to be converted to string (since it will be a number type)

Badge +3

Hi @EricSullivan ,

 

You can keep a counter as mentioned below and increment the same while looping through each row of that table.

 

//div[@id='teamFoldersSlideoutContent']/div[3]/div[1]/div[1]/div[1]/table[1]/tbody[1]/tr[$Counter$]/td[2]/div[1]/div[1]

 

Keep in mind that the Counter variable has to be converted to string (since it will be a number type)

Hey @Padmakumar ,

 

I think he wants to extract/click the last item and as it is a table the get rows and passing it to the xPath will work right?

Userlevel 7
Badge +10

@EricSullivan ,

Sorry, I misinterpreted. 


In your case, try using any other Object property (innerHTML or HTML Value) which is consistent throughout the environmental changes. I don’t think DOMX Path would be a good option here. 

Reply