如果要遍历所有图元,则不单击。然后
获取以下文本。它显示它包含466个结果。
466项结果中的401-466项
所以你的第一个url是
?offset=0&count=100
?offset=100&count=100
第三
?offset=200&count=100
第四
?offset=300&count=100
最后的
?offset=400&count=100
你可以做数学题。
然而,若你们想点击下拉选项,那个么。
xpath = "//div[@data-test='select-container']"
wait.until(EC.visibility_of_element_located((By.XPATH, xpath)))
wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
webDriver.find_element_by_xpath(xpath).click()
在这之后和新的
div
正在添加的元素具有
span
谢谢你的选择。您共享的html代码,与此无关。
<div class="Pt(5px) Pb(5px) Pos(a) End(0px) Z(10) Bgc(#fff) Bd Bdc($c-fuji-grey-c) Bdrs(2px) Bxsh($boxShadow) Whs(nw)" data-test="showRows-select-menu">
<div class="Ta(start) Px(20px) Py(10px) Cur(p) Bgc($pillBgBlue):h Fz(s)" data-value="25">
<span>Show 25 rows</span>
</div>
<div class="Ta(start) Px(20px) Py(10px) Cur(p) Bgc($pillBgBlue):h Fz(s)" data-value="50">
<span>Show 50 rows</span>
</div>
<div class="Ta(start) Px(20px) Py(10px) Cur(p) Bgc($pillBgBlue):h Fz(s) Fw(b)" data-value="100">
<span>Show 100 rows</span>
</div>
</div>
所以你需要做的是,在你点击
link
您需要等待该元素添加到html中。
xpath = "//div[@data-test='showRows-select-menu']"
elem = wait.until(EC. presence_of_element_located((By.XPATH, xpath)))
total_dropdown = len(driver.find_elements_by_xpath("//div[@data-test='showRows-select-menu']/div")
driver.find_elements_by_xpath("//div[@data-test='showRows-select-menu']/div[total_dropdown+1]/span").click()
我还没有测试代码,但是我想你已经知道了。