Reputation: 3534
I am writing selenium tests, and I need to switch to an iframe with no id or name and which parent element contains variable id's (so not helpful. Also, the src
attribute has variable data in it as well, so I can't target it directly like By.cssSelector("iframe[src='example']")
. I need an xpath selector that targets the src, but also that uses contains. I am trying to learn how to build xpaths outside of Chrome's Copy XPath
but I can't figure this one out. Thanks for your help! Here is the iframe html:
<iframe scrolling="auto"
src="/admin/catalog/manage_variants_in_product.jsp?productId=160502"
width="100%" height="100%" frameborder="no"
style="position:absolute; top:0px; left:0px;">
</iframe>
Upvotes: 2
Views: 865
Reputation: 7708
The better way I would recommend to learn building xpath or csspath is Firepath
add-on of Firefox
First install Firebug in your Firefox browse and then install Firepath.
There you will get the efficient way to get the xpath or evaluate the xpath build by yourself
Upvotes: 0
Reputation: 473863
The "contains" CSS selector might help here:
iframe[src*=manage_variants_in_product]
FYI, there are also ^=
and $=
that mean "starts with" and "ends with" respectively.
Upvotes: 2