Python 有没有办法让selenium忽略timeoutexception错误并在发生时继续?

Python 有没有办法让selenium忽略timeoutexception错误并在发生时继续?,python,selenium,Python,Selenium,我将selenium与python一起使用,我的chromedriver和chrome.exe版本为90.0 我有一个问题,脚本将停止一旦超时错误发生,问题是它总是发生,有时在几个小时内,有时在几分钟内 它将显示如下内容: selenium.common.exceptions.timeoutexception: message: timeout: timed out receiving message from renderer: -0.014 当这种情况发生时,我看到网页通常正在加载,它基本

我将selenium与python一起使用,我的chromedriver和chrome.exe版本为90.0

我有一个问题,脚本将停止一旦超时错误发生,问题是它总是发生,有时在几个小时内,有时在几分钟内

它将显示如下内容:

selenium.common.exceptions.timeoutexception: message: timeout: timed out receiving message from renderer: -0.014
当这种情况发生时,我看到网页通常正在加载,它基本上无法加载,导致错误发生

有没有一种方法可以忽略此错误,让脚本刷新或继续加载到列表中的下一个网页。示例代码如下所示:

while True:
     driver.get(thislist[i])
     if .......:
        i = i + 1
我尝试了很多修复方法,但都不管用。我试过使用beta chrome.exe和chrome webdriver版本91.0。我还尝试了包括chrome_选项,还尝试了一些代码中没有的标题,但我总是收到超时错误。我以前问过几次这个问题,但至今还没有一个有效的解决办法

chrome_options.add_argument('--enable-automation')
chrome_options.add_argument('--lang=en')

chrome_options.add_argument("window-size=1920,1080")
chrome_options.headless = True


chrome_options.add_experimental_option ("debuggerAddress", "localhost:8989")
driver = webdriver.Chrome(executable_path='C:/Webdriver/chromedriver', chrome_options=chrome_options)
   
     

在引发错误的操作周围添加一个
try catch
怎么样。如果出现错误,只需在循环中继续

使用
Exception
,因为您不知道将引发的异常类型


您始终可以使用以下行将selenium的超时时间设置为更长:
driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS)

当存在timeoutexception时,代码将只打印它并继续下一个循环。如果没有人,那么您可以在“else:”下进行web驱动

谢谢你的阅读

while True:
    try:
        driver.get(thislist[i])
    except timeoutexception as e:
        print(e)
        continue
    else:
        # do what you want here