【发布时间】:2016-08-27 14:08:30
【问题描述】:
我正在尝试根据下一列的文本选择 webtable 的上一列。这是我的代码:
for(WebElement eachrow:noofrows)
{
List<WebElement> col3=eachrow.findElements(By.xpath("//td[3]"));
for(WebElement text:col3)
{
String s1=text.getText();
System.out.println(s1);
if(s1==opt1)
{
driver.findElement(By.xpath("//td[2]")).click();
}
}
if(t.equals(choice1)||t.equals(choice2))
{
text.findElement(By.xpath("//td[2]")).click();
}
这里是html:
style="display: table-cell; vertical-align: top; -moz-user-select: none;">
<div class="ib10_checklist_question">An angel investor is the best choice. Why? Select up to two reasons. This is the appropriate funding amount for an angel investor. Angel investors are the best choice for backing an idea to get off the ground. Angel investors are backed by churches. Angel investors have limitless funds. </div>
<div class="ib10_checklist_bg">
<table style="width:100%">
<tbody>
<tr style="height:10%">
<td style="width:5%"/>
<td style="width:5%">
<div class="ibg_checkbox" onclick="if (c2_callFunction) c2_callFunction('lvl2_check',[0]);">b</div>
</td>
<td class="ib10_checklist_text" style="width:100%">This is the appropriate funding amount for an angel investor.</td>
</tr>
【问题讨论】:
-
将
html代码作为文本添加到您的问题中,而不是附加图像!还要澄清哪个是目标元素,并在出现任何错误时指定错误。谢谢 -
根据
谢谢
标签: selenium dom html-table