<div id="ContentPrimary">
<ul class="selectors modeSelectors">
<li><a href="/content/l411846326l1213g/references/" title="">
<span class="selector">References (27)</span></a></li>
<li><a href="/content/l411846326l1213g/referrers/" title="">
<span class="selector">Cited By (2)</span></a></li>
<li><a href="/content/l411846326l1213g/export-citation/" title="">
<span class="selector">Export Citation</span></a></li>
<li><a href="/content/l411846326l1213g/about/" title="">
<span class="selector">About</span></a></li>
</ul>
在此我需要找到并使用Selenium API单击关于链接,但我无法做到这一点。
我所做的是
wait.until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver webDriver) {
System.out.println("Searching ...");
String s = driver.findElement(By.cssSelector("#ContentPrimary ul li[4] span.selector")).getText();
System.out.println(s);
if (Pattern.compile(Pattern.quote("About"), Pattern.CASE_INSENSITIVE).matcher(s).find()) {
return true;
} else {
return false;
}
}
});
driver.findElement(By.linkText("About")).click();
但它不工作