Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
ccwolters
Posts : 1
Join date : 2012-06-23

Tough element to locate, need help Empty Tough element to locate, need help

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')]
avatar
cyssor
Posts : 5
Join date : 2012-06-15

Tough element to locate, need help Empty Re: Tough element to locate, need help

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.

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