我正在尝试使用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;
在运行脚本时,我得到一个错误消息"无法识别元素"。如果有需要修改的地方请帮助我
有许多xpaths
可以帮助您在上述情况下找到h3
,让我列出几个:
xpath = "//div[@id='paymentSection']//h3"
using text:
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"