Geeks With Blogs

News QTP and Stuff
Theo Moore Questions... Morphology? Longevity? Incept dates?
Ran into an interest limitation with Selenium today. I am trying to interact with an anchor tag/link. Trouble is that the link is one of several on the page that have similar names. The best way to get at it is via the id attribute, since they are dynamically generated and are unique (not that it matters, but the number appended to the text is a db ID). So, I figure I can use a regexp to evaluate the link so;"id=regexp:playMovie[0-9]*");

The [0-9]* should allow for any number of digits after the playMovie. However, when I evaluate the expression with isElementPresent, a big, fat false is returned. How could that be?

I thought perhaps my syntax was wrong, but I don't think it is. So, I tried something different. I tried another link and did this:"link=regexp:Just [A-Za-z]*");

This should find the first instance of a link with "Just" as the first 4 characters followed by a space. Interestingly, this works. My syntax is correct, so what could the problem?

I have come to the conclusion that the regexp: modifier will not work with "id=" locator, although that doesn't make a lot of sense. I've seen examples on the web that seem to suggest some others have this working correctly.

Hopefully I'll have more on this as I figure it out.
Posted on Tuesday, March 10, 2009 9:08 AM | Back to top

Comments on this post: Selenium: RegExp with ID attribute

# re: Selenium: RegExp with ID attribute
Requesting Gravatar...
I don't use Selenium but use QTP. I've noticed that the ID tag on a link is referred as "html id" instead of "id". So if you use html id it may work for you.

Like I said this is what I've found to be the case for QTP and Selenium may work differently.
Left by Percy on Mar 10, 2009 9:58 PM

# re: Selenium: RegExp with ID attribute
Requesting Gravatar...
Thank you for the comment!

No, selenium doesn't use identifiers in in the same way QTP does (I've used QTP on and off for years), but thank you for the suggestion. Much appreciated. :-)

Left by Theo on Mar 11, 2009 8:31 AM

Comments have been closed on this topic.
Copyright © Theo Moore | Powered by: