java - Selenium - how to select an element with variable text -


<div class="order-number"> <h3>"order number: "<strong>123-123123</strong> </h3> </div> 

any idea how select order number? use selenium 2. tried this:

driver.findelement(by.xpath(".//*[matches(text(),'\\d+-\\d+']")); 

but it's not working. xpath2 support regex?

the number of order different, style of xxx-xxxxxx same.

a different approach search css selector instead:

by.cssselector(".order-number h3 strong") 

it's bit more frail if page structure changes though.

a better solution (if able change page code) put id on <strong> tag , use by.id. that's quicker, less frail, , more readable xpaths or css-selectors.


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -