Testing 标识类中存在的表中的表数据
如何识别Testing 标识类中存在的表中的表数据,testing,selenium,webdriver,selenium-webdriver,Testing,Selenium,Webdriver,Selenium Webdriver,如何识别td元素中存在的div数据并单击该元素 这些td元素将动态生成,我们需要发现它由姓名和电话号码等联系人详细信息组成。使用id <div class="row-fluid"> <table class="s-table table table-bordered table-striped table-hover"> <thead class="p-table-head"> <tbody class="
td
元素中存在的div
数据并单击该元素
这些
td
元素将动态生成,我们需要发现它由姓名和电话号码等联系人详细信息组成。使用id
<div class="row-fluid">
<table class="s-table table table-bordered table-striped table-hover">
<thead class="p-table-head">
<tbody class="p-table-body">
<tr>
<td>
<td>
<div id="div_2_1_2_1_2_r1" class="String CoachView CoachView_show" data-eventid="" data-viewid="Table_Column1" data-config="config_div_2_1_2_1_2_r1" data-bindingtype="String" data-binding="local.customerContacts[index].name" data-type="com.ibm.bpm.coach.Snapshot_a30ea40f_cb24_4729_a02e_25dc8e12dcab.String" data-bindingrt="local.customerContacts[0].name">
</td>
<td>
<td>
<td>
<td>
<td>
</tr>
另外,对于任何其他标签也是如此。不要忘记关闭打开的TDs。您也可以这样做。在下面的示例中,您可以使用。/td。本例搜索包含值
all
的td
。如果它找到了它,那么点击td
中的锚。可能对您有用
<td id="findme"> </td>
List elements=driver.findElements(By.xpath(“//table/thead/tr”);
for(Iterator Iterator=elements.Iterator();Iterator.hasNext();){
WebElement WebElement=iterator.next();
List findElement=webElement.findElements(By.xpath(“./td”);
如果(findElement.size()>0){
if(findElement.get(0.getText()!=null&&findElement.get(0.getText().indexOf(“全部”)!=1){
List-aeelement=webElement.findElements(By.xpath(“./td/a”);
AEElement.get(0).单击();
打破
}
}
}
List<WebElement> elements = driver.findElements(By.xpath("//table/thead/tr"));
for (Iterator<WebElement> iterator = elements.iterator(); iterator.hasNext();) {
WebElement webElement = iterator.next();
List<WebElement> findElement = webElement.findElements(By.xpath("./td"));
if( findElement.size() > 0 ){
if( findElement.get(0).getText() != null && findElement.get(0).getText().indexOf("all") != -1 ) {
List<WebElement> aElement = webElement.findElements(By.xpath("./td/a"));
aElement.get(0).click();
break;
}
}
}