Display results as :

Rechercher Advanced Search


Tough element to locate, need help

View previous topic View next topic Go down

Tough element to locate, need help

Post by ccwolters on Sat Jun 23, 2012 1:07 pm

I have seen the posts on using XPATh to locate dynamic elements. However, I have not seen anyone with a problem like this:

I am trying to click on a link that expands and collapses a div area. The image is named dynamically for example on the first page load the image for this icon will be named img_24, but when I refresh, the name changes to img_32. There are a number of these icons on a page, each associated with a gadget. So, when img_24 changes to img_32, it will now open a different gadget on the page. Can XPATH be used to locate an element using 2 test, one for the title of the gadget (which is constant) and a 2nd for the pattern matching for img_??

XPath: //button[starts-with(@id, 'img_')] AND //text in the same frame[starts-with('Gadget Number 10')]


Posts : 1
Join date : 2012-06-23

Back to top Go down

Re: Tough element to locate, need help

Post by cyssor on Mon Jun 25, 2012 9:54 pm

I'm pretty sure Selenium allows you to "pipe" in a format similar to (using your example)

XPath: //button[starts-with(@id, 'img_')] | //button[starts-with('Gadget Number 10')]

Not exactly sure if that is the correct statement but I would suggest looking up the usage of " | " in Selenium.

Example from W3schools.

//book/title | //book/price Selects all the title AND price elements of all book elements
//title | //price Selects all the title AND price elements in the document
/bookstore/book/title | //price Selects all the title elements of the book element of the bookstore element AND all the price elements in the document.

Hope this helps some.


Posts : 5
Join date : 2012-06-15

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum