How do we use @POS with XPATH? Alternative?

I’m trying to figure out how to use @POS with a user-defined variable counter instead of {!LOOP}.

What I’m trying to do:


Position support in link text locator

With CLICK link=Download@POS=3 you instruct the IDE to use the n-th (here n=3) occurrence of a locator. This is useful, for example, if a have a website with many download links, and you want to click the n-th once. POS is only supported with the “normal text” locator link=… but not with XPATH and CSS selectors.

So what’s an alternative to what I’m trying to accomplish?

The correct xpath notation is xpath=(//*[text()[contains(.,'Download')]])[6], so in your case xpath=(//*[text()[contains(.,'Download')]])[${COUNTER}]

See FAQ: How can I find the n-th link with a specific text with XPath?