首页 > 解决方案 > 如何解决 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')))

我如何得到这个错误?

标签: pythonseleniumgoogle-chrome

解决方案


WebDriverWait对我也不起作用,但 usingwhiletry exceptblock 有效。

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


推荐阅读