【发布时间】:2017-12-11 18:14:53
【问题描述】:
找到带有 xpath 或 CSS 的元素列表(在浏览器控制台中的结果相同)
int alltips = driver.findElements(By.xpath("//div[@class='column medium-12']//div/ul/li")).size();
int alltips1 = driver.findElements(By.cssSelector("ul.feed-tips#Grid > li.feed-item")).size();
System.out.println(alltips);
System.out.println(alltips1);
由于两次打印得到了相同的结果(一个页面上存在 21 个 'li' 容器) 但是,当把它放在 selenium webdriver 中时,我得到了相同的结果并且它为零。 从控制台添加屏幕截图
我做错了什么?
这是 HTML 的一部分:
<div class="column medium-12">
<h1>Free Tips</h1>
<p>Here you'll always find the latest tips posted by our international community of sports betting tipsters. If you're ever in need of inspiration for a bet, this is the place to be! </p>
<div class="row">
<ul class="feed-tips" id="Grid" data-sport="" data-country="" data-
league="">
下面的 HTML 看起来和截图一样:
【问题讨论】:
-
请分享
HTML。 -
@DebanjanB 不幸的是,它没有直播,所以我会把你送到这里