我正在尝试使用xpath在Mozilla浏览器中识别一个WebElement。以下是html代码:
<div id="address-book" class="grid-12" style="display:none;">
<!-- END ADDRESS BOOK -->
<!-- BEGIN PAYMENT OPTIONS -->
<div id="paymentSection" class="grid-12 form-section">
<div class="grid-contentx">
<div class="hd header-container">
<h3>Payment Information</h3>
</div>
</div>
<!-- BEGIN: CC FORMS -->
<div class="grid-6">我在页面对象工厂中编写的相关xpath是:
@FindBy(xpath = "//*[@id='paymentSection']/div[1]/div/h3")
private WebElement paysection;在运行脚本时,我会收到一条“无法识别元素”的错误消息。如果需要对已识别的xpath进行任何更正,请帮助我。
发布于 2014-03-16 15:36:57
在上述情况下,有许多xpaths可以帮助您找到h3,下面我列出几个:
使用id :
xpath = "//div[@id='paymentSection']//h3"使用文本:
xpath = "//h3[contains(.,'Payment Information')]"使用类名:
xpath = "//div[@id='paymentSection']//div[@class='hd header-container']/h3"使用id和类名:的组合
xpath = "//div[@id='paymentSection' and @class='grid-12 form-section']//h3"https://stackoverflow.com/questions/22433174
复制相似问题