【发布时间】:2018-08-16 00:22:19
【问题描述】:
我正在尝试刷新页面,直到项目出现,但我的代码不起作用(我对此采取了模式:python selenium keep refreshing until item found (Chromedriver))。
代码如下:
while True:
try:
for h1 in driver.find_elements_by_class_name("name-link"):
text = h1.text.replace('\uFEFF', "")
if "Puffy" in text:
break
except NoSuchElementException:
driver.refresh
else:
for h1 in driver.find_elements_by_class_name("name-link"):
text = h1.text.replace('\uFEFF', "")
if "Puffy" in text:
h1.click()
break
break
这些片段是因为我必须找到一个具有相同类名的项目并将 BOM 替换为“”(find_element_by_partial_link_text 不起作用)。
for h1 in driver.find_elements_by_class_name("name-link"):
text = h1.text.replace('\uFEFF', "")
if "Puffy" in text:
break
有人可以帮我吗?非常感谢。
【问题讨论】:
-
为什么页面上没有项目?为什么刷新会让它们出现?
标签: python html selenium refresh zero-width-space