Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in RPA by (5.8k points)

In Workfusion I am iterating all elements in a HTML page that are to be found by xpath:

//*[starts-with(@id,"FormView1_hidRevElement")][${i}]

When ${i} = 1 I get what is expected but not when ${i} > 1.

In the HTML page I have elements like:

id="FormView1_hidRevElement12636"

id="FormView1_hidRevElement12637"

id="FormView1_hidRevElement12642"

etc,

Error thrown: 

Caused by: 

org.openqa.selenium.NoSuchElementException: Unable to locate element: //*[starts-with(@id,"FormView1_hidRevElement")][2]

1 Answer

0 votes
by (29.5k points)

The XPath which you have created is wrong because

//*[starts-with(@id,"FormView1_hidRevElement")]

this will return the matching count as 3 for the below id's

id="FormView1_hidRevElement12636"

id="FormView1_hidRevElement12637"

id="FormView1_hidRevElement12642"

And each id match equals 1 then obviously >1 condition will throw an error because it doesn't exist.

instead of that you can try using this :

(//*[starts-with(@id,"FormView1_hidRevElement")])[${i}]

Related questions

0 votes
1 answer
0 votes
1 answer

Browse Categories

...