Click a link with selector change everytime

Hello, I’m very gratitude all the help so far. I have a question today with the selector:

xpath=//*[@id="jsc_c_dh"]/span[2]/span/a/span/span/b/b[13]

I want to use click and click a link, I’m trying:

xpath=//*[contains(@id,"jsc_c_")]/span[2]/span/a/span/span/b/b[contains(number(),"")]

But it’s not working, is it wrong? I’m only see the text feature so I tried it with number instead. I can’t use the xclick because:

  • The text link change when when time run like: 1 hour - 2 hours - 3 hours - ect.

Many thank for all answers.

See here: How to get the Selenium IDE commands to work with dynamic ID's

You can use an axes xpath (not recorder by ui vision) to detect dynamic and relative elements in the page

May I don’t clarifying about it from the start, but the ID working fine, the problem in here is the b[13], I’m not sure how to target them. When the page reload, it will change from b[13] to b[3] or b[40] …

I tried to changed it with the following or child but it still doesn’t work:

xpath=//*[contains(@id,"jsc_c_")]/span[2]/span/a/span/span/b//following::b

I tried to change it to:

Xpath=//*[contains(@id,"jsc_c_")]//span[2]//span//a//span//span//b

And it still not the final solution although the select send found the DOM but the click not take action because I’m still not sure how to target to the last b tags with dynamic number.

Screenshot

Example: Facebook

Need axes xpath this is the hard part to study

With this you can solve your problem

1 Like

Yes, I can see it’s absolute powerful with the axes, but I tried to change it again with:

Xpath=//*[contains(@id,"jsc_c_")]//span[2]//span//a//span//span//b//child::b

But it still not work for me. May you can help me with more hints about it?