0
无法检索列表中的所有元素 我试图使用“选择”,它是抛出错误信息。任何人都可以请告诉我,如何检索所有元素?目前的代码只能检索到5个元素。请查阅网站的我的代码硒WebDriver - 无法检索列表中的所有元素
继输出元素的列表
<h3 class="tout__title complex-link__target theme__target"> Almost Naked Animals </h3>
<h3 class="tout__title complex-link__target theme__target"> Amazing Animal Births </h3>
<h3 class="tout__title complex-link__target theme__target"> American Dad! </h3>
<h3 class="tout__title complex-link__target theme__target"> An Audience with... </h3>
<h3 class="tout__title complex-link__target theme__target"> Arsenal Pre-Season Friendlies </h3>
<h3 class="tout__title complex-link__target theme__target"> Atlanta Plastic </h3>
<h3 class="tout__title complex-link__target theme__target"> Audi Cup </h3>
<h3 class="tout__title complex-link__target theme__target"> The Avatars </h3>
我的代码是:
wait.until(visibilityOfElementLocated(By.cssSelector("h3[class='tout__title complex-link__target theme__target']")));
List<WebElement> pgm= alp.findElements(By.cssSelector("h3[class='tout__title complex-link__target theme__target']"));
System.out.println(pgm.size());
for(WebElement e: pgm)
{
System.out.println("List of Shows "+e.getText());
}
输出:
Size of the Element(Total) :8
List of Shows Almost Naked Animals
List of Shows Amazing Animal Births
List of Shows American Dad!
List of Shows An Audience with...
List of Shows Arsenal Pre-Season Friendlies
List of Shows Atlanta Plastic
List of Shows
List of Shows
它'pgm.size()=='8真的吗?如果是的话,我强烈怀疑你发布的html代码是正确的。你有链接到这个网站? –
HI Ivan - 该网站是:https://www.itv.com/hub/shows。如果你有解决方案,请告诉我 – sri