每个切换按钮都有多个切换按钮但类名相同。
此处代码
<div class="col-md-10 blockBox">
<h4 class="panel-title">
<a class="accordion-toggle collapsed" href="#CompetencyBlock" data-parent="#CompetencyAccordion" data-toggle="collapse">
Forms And Assessments For Individuals
<div class="tabHeaderImage"></div>
</a>
</h4>
</div>
<div class="col-md-10 blockBox">
<h4 class="panel-title">
<a class="accordion-toggle collapsed" href="#BirthDateBlock" data-parent="#BirthDateAccordion" data-toggle="collapse">
Birthdate
<div class="tabHeaderImage"></div>
</a>
</h4>
</div>
我试过这些代码
1) List<WebElement> text = driver.findElements(By.className("panel-title"));
text.get(2).click();
2) List<WebElement> text = driver.findElements(By.className("tabHeaderImage"));
text.get(2).click();
但我可以点击前四个切换按钮仅剩下切换按钮我无法点击
答案 0 :(得分:0)
List<WebElement> text = driver.findElements(By.xpath("//h4[@class='panel-title']/following-sibling::a"));
text.get(0).click();
你应该找到锚标签,因为锚标签只是可点击的..div和h4标签是不可点击的