How to use dynamic xpath in tosca

Viewed 417

I have a scenario where I have to use xpath to identify the element . However I want the xpath to be dynamic and the parameter that I pass to xpath should be based on buffer that I stored as part of the test run.

Is it possible to give buffer value in xpath ?

2 Answers

Yes, it is possible. You must put the buffer name in quotes. Here how I use it to iterate over Number for div[Number]:

"id('table')/div["{B[Number]}"]"
                 ^-----------^ < note the quotes

Have you tried with {B[your_buffer_name]} within your xpath? I never tried using a buffer in a property but that may work.

I would also suggest finding other ways of uniquely identifying your elements. IMHO xpath is rather prone to being unstable. Any change in the page structure will likely break it.

Related