python - 如何解决 python 说“WebDriverException:: unknown error: cannot determine loading status from no such execution context?”的问题?
问题描述
当我进行网页抓取时发生错误。带有硒
错误消息:
WebDriverException: Message: unknown error: cannot determine loading
status from no such execution context (Session info: chrome=73.0.3683.103)
(Driver info: chromedriver=73.0.3683.68
(47787ec04b6e38e22703e856e101e840b65afe72),platform=Windows NT 6.1.7601
SP1 x86_64)
当新窗口延迟时,会出现以下错误。我尝试使用 Google 搜索,但找不到解决方案。
代码:
driver.switch_to.window(driver.window_handles[1])
WebDriverWait(driver,
60).until(EC.presence_of_element_located((By.CSS_SELECTOR,'#listForm >
div.contents_sub > div.cont_area > div > table.board_view.fix > tbody
> tr:nth-child(2) > td')))
我如何得到这个错误?
解决方案
WebDriverWait
对我也不起作用,但 usingwhile
和try except
block 有效。
from selenium.common.exceptions import WebDriverException
...
driver.switch_to.window(driver.window_handles[1])
form = None
while form is None:
try:
form = driver.find_element_by_id('loginform')
except WebDriverException:
pass
print(form)
此外,我建议尝试geckodriver。
推荐阅读
- c# - 从用户上下文应用程序(C#、控制台应用程序)访问系统应用程序数据
- java - 如何为 Wear Os 发出通知?
- ios - performSegue 视图不在窗口层次结构中
- java - LocalDate.parse 是否默默地纠正了天数?
- python - 使用 Python 后台脚本捕获屏幕截图并保存到文档
- networking - Openshift/Kubernates kube dns 最佳实践 (ndots = 5)
- sql - Pivot, CONCAT, 一张表和 INNER JOIN 与另一张表创建单表
- python - 使用代码自定义 Jupyter Notebook 单元格行为
- python - 如何从 url 获取文件缺少的内容长度?
- javascript - 如何使在线会员柜台即时更新?