简体   繁体   中英

want to identify element with JSP core<c:if> tag using selenium webdriver using xpath or any other locators

<tr class="odd" role="row">
<td>PRODTUT020</td>
<td>Product for tours</td>
<td>
<td>
<ul class="icons-list">
<c:if test="true">
<li class="text-info-600">
<a href="edit-se-product_mst-90" title="View">
<i class="icon-eye"/>
</a>
</li>
</c:if>
</ul>
</td>
</tr>

Above is the html body. Want to click on the icon-eye element. How do we identify this element using selenium locators?

This XPath,

//tr[td="PRODTUT020"]//i[@class="icon-eye"]

will select i elements with @class attribute value of icon-eye beneath the tr element whose td child has a string value of PRODTUT020 .

Depending upon what's more invariant across your general cases, you might change PRODTUT020 to Product for tours -- both work for the case you show.

It avoids having to name the namespaced element by skipping past it via // .

如果要在c:if元素中获取i ,可以使用以下表达式

'//*[name()="c:if" and @test="true"]//i'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM