Selenium mozilla浏览器中的Xpath webelement标识

Selenium mozilla浏览器中的Xpath webelement标识,selenium,xpath,mozilla,Selenium,Xpath,Mozilla,我试图使用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"> <di

我试图使用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进行任何更正,请帮助我。

有许多
xpath
可以帮助您定位
h3
在上述情况下,让我列出一些:

使用id:

xpath = "//div[@id='paymentSection']//h3"
xpath = "//h3[contains(.,'Payment Information')]"
xpath = "//div[@id='paymentSection']//div[@class='hd header-container']/h3"
xpath = "//div[@id='paymentSection' and @class='grid-12 form-section']//h3"
使用文本:

xpath = "//div[@id='paymentSection']//h3"
xpath = "//h3[contains(.,'Payment Information')]"
xpath = "//div[@id='paymentSection']//div[@class='hd header-container']/h3"
xpath = "//div[@id='paymentSection' and @class='grid-12 form-section']//h3"
使用类名:

xpath = "//div[@id='paymentSection']//h3"
xpath = "//h3[contains(.,'Payment Information')]"
xpath = "//div[@id='paymentSection']//div[@class='hd header-container']/h3"
xpath = "//div[@id='paymentSection' and @class='grid-12 form-section']//h3"
使用id类名的组合:

xpath = "//div[@id='paymentSection']//h3"
xpath = "//h3[contains(.,'Payment Information')]"
xpath = "//div[@id='paymentSection']//div[@class='hd header-container']/h3"
xpath = "//div[@id='paymentSection' and @class='grid-12 form-section']//h3"

//div[@class=“hd header container”]/h3是否有效?我看到下面的xpath//div[@class=“hd header container”]/h3有三个匹配的节点,好的,让我们把它缩小到
//div[@class=“grid context”]/div[@class=“hd header container”]/h3
。我尝试了上述所有选项,但仍然无法找到元素错误。如果有任何解决问题的方法,请帮助我。我没有将等待元素用作待测应用程序的页面,并且有足够的时间来识别元素。我只是重新检查并“//div[@id='paymentSection'和@class='grid-12表单部分]//h3”工作正常。感谢您的帮助!