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]
...
What is wrong?
The XPath which you have created is wrong because
//*[starts-with(@id,"FormView1_hidRevElement")]
will return the matching count as 3 for the below id's
id="FormView1_hidRevElement12636"
id="FormView1_hidRevElement12637"
id="FormView1_hidRevElement12642"
And the each id match equals to 1 then obviously >1 condition will throw an error because it doesn't exist.
Try this XPath:
(//*[starts-with(@id,"FormView1_hidRevElement")])[${i}]