Dom 如何识别HTML页面页脚中的页面导航按钮以在Selenium中单击它?
我需要识别表单页脚处的页面导航按钮,如果该按钮处于活动状态,请单击>>>(最后一页)按钮,否则根本不要单击它Dom 如何识别HTML页面页脚中的页面导航按钮以在Selenium中单击它?,dom,selenium,xpath,Dom,Selenium,Xpath,我需要识别表单页脚处的页面导航按钮,如果该按钮处于活动状态,请单击>>>(最后一页)按钮,否则根本不要单击它 <table id="prefixmasterListForm:prefixMasterTable:j_id256_table" class="rich-dtascroller-table " cellspacing="1" cellpadding="0" border="0" style="text-align:right"> <tbody> <
<table id="prefixmasterListForm:prefixMasterTable:j_id256_table" class="rich-dtascroller-table " cellspacing="1" cellpadding="0" border="0" style="text-align:right">
<tbody>
<tr>
<td class="rich-datascr-button-dsbld rich-datascr-button">
««
</td>
<td class="rich-datascr-button-dsbld rich-datascr-button"></td>
<td class="rich-datascr-act ">
1
</td>
<td class="rich-datascr-inact " onclick="Event.fire(this, 'rich:datascroller:onscroll', {'page': '2'});"></td>
<td class="rich-datascr-inact " onclick="Event.fire(this, 'rich:datascroller:onscroll', {'page': '3'});"></td>
<td class=" rich-datascr-button" onclick="Event.fire(this, 'rich:datascroller:onscroll', {'page': 'next'});"></td>
<td class=" rich-datascr-button" onclick="Event.fire(this, 'rich:datascroller:onscroll', {'page': 'last'});"></td>
</tr>
</tbody>
««
1.
在上述场景中,启用了第一页>
2) 点击那个按钮
那么什么是DOM或XPath来获取要单击的适当元素呢?我没有看到DOM元素上的“>>>”。我假设它也在元素下
element = driver.FindElement(By.XPath, "//td[contains(.,'>>>')]")
if (!element.getAttribute("class").contains("rich-datascr-button-dsbld")) // should not have
{
element.click();
}
可以使用xpath获取表中td的类。我认为在类rich datascr button dsbld rich datascr button中,dsbld指定按钮被禁用。您可以使用String class contains方法来确定类中是否存在文本。如果存在,则按钮被禁用。否则它将被启用。这只是一种预感。让我知道这是否有效。您需要Selenium IDE或java/python/ETCPlese的代码。如果您认为这可以解决您的问题,请标记答案。;)