Skip to main content

DOMXPATH ISSUE

  • 12 January 2024
  • 2 replies
  • 86 views

I want to capture the green highlighted domxpath in a list from an application however this needs to be dynamic, so every time the bot can click on the element.If you see they is a pattern in the domxpath list however when it captures the blue highlighted domxpath and move to the next element which is the green highlighted domxpath it has a seven and not a six .When I do an html inspect in chrome it shows they is a hidden element between divi5] and divi7].How do I dynamically capture the element?

//formr@name='form']/divi5]/divi2]/divi1]/divi2]/divi1]/divi1]/divi1]/p/1]/labele1]
//formr@name='form']/divi5]/divi2]/divi1]/divi2]/divi2]/divi1]/divi1]/p/1]/labele1]
//formr@name='form']/divi5]/divi2]/divi1]/divi2]/divi3]/divi1]/divi1]/p/1]/labele1]
//formr@name='form']/divi5]/divi2]/divi1]/divi2]/divi4]/divi1]/divi1]/p/1]/labele1]
//formr@name='form']/divi5]/divi2]/divi1]/divi2]/divi5]/divi1]/divi1]/p/1]/labele1]
//formr@name='form']/divi5]/divi2]/divi1]/divi2]/divi7]/divi1]/divi1]/p/1]/labele1]
//formr@name='form']/divi5]/divi2]/divi1]/divi2]/divi8]/divi1]/divi1]/p/1]/labele1]

2 replies

Userlevel 6
Badge +15

Hi @Lesley ,

Please find the information below regarding passing the counter/increment variable in the DOMX Path  div[vCounter]. 

Firstly, determine the total number of items in the list. Iterate through the list to retrieve values based on the total count. For instance, if your application's list contains 10 records, the total count is 10. You should then iterate 10 times to obtain all the values from the list.

//form[@name='form']/div[5]/div[2]/div[1]/div[2]/div[vCounter]/div[1]/div[1]/p[1]/label[1]

Note : Convert the numeric counter variable to a string and include it in the XPath

 

 

 

 

 

Badge

I want to capture the green highlighted domxpath in a list from an application however this needs to be dynamic, so every time the bot can click on the element.If you see they is a pattern in the domxpath list however when it captures the blue highlighted domxpath and move to the next element which is the green highlighted domxpath it has a seven and not a six .When I do an html inspect in chrome it shows they is a hidden element between div[5] and div[7].How do I dynamically capture the element?

//form[@name='form']/div[5]/div[2]/div[1]/div[2]/div[1]/div[1]/div[1]/p[1]/label[1]
//form[@name='form']/div[5]/div[2]/div[1]/div[2]/div[2]/div[1]/div[1]/p[1]/label[1]
//form[@name='form']/div[5]/div[2]/div[1]/div[2]/div[3]/div[1]/div[1]/p[1]/label[1]
//form[@name='form']/div[5]/div[2]/div[1]/div[2]/div[4]/div[1]/div[1]/p[1]/label[1]
//form[@name='form']/div[5]/div[2]/div[1]/div[2]/div[5]/div[1]/div[1]/p[1]/label[1]
//form[@name='form']/div[5]/div[2]/div[1]/div[2]/div[7]/div[1]/div[1]/p[1]/label[1]
//form[@name='form']/div[5]/div[2]/div[1]/div[2]/div[8]/div[1]/div[1]/p[1]/label[1]

Hi @Lesley,

Arasu has given a correct solution.
only thing which is missing is the try catch.

Loop
   Counter +1

   try

      recorder with dynamic Xpath //form[@name='form']/div[5]/div[2]/div[1]/div[2]/div[$nCounter.Number:toString$]/div[1]/div[1]/p[1]/label[1]

  catch

In this case even if there is a missing element it will skip to the next

Reply