无法访问Python Selenium Chrome

无法访问Python Selenium Chrome,python,selenium,selenium-webdriver,error-handling,whatsapp,Python,Selenium,Selenium Webdriver,Error Handling,Whatsapp,我的脚本在打开的头几天运行良好。但通常不能维持超过3天。打开浏览器时脚本开始循环,进入whatapps页面并关闭它。我试图在运行之前杀掉所有的Chrome,但似乎不是问题所在。我怎样才能解决它 这是我的剧本 def sdWhatApps_noteice(name, msg): run = False while not run: try: subprocess.call("TASKKILL /f /IM CHROME.EXE") ch

我的脚本在打开的头几天运行良好。但通常不能维持超过3天。打开浏览器时脚本开始循环,进入whatapps页面并关闭它。我试图在运行之前杀掉所有的Chrome,但似乎不是问题所在。我怎样才能解决它

这是我的剧本

def sdWhatApps_noteice(name, msg):
run = False
while not run:
    try:
        subprocess.call("TASKKILL /f  /IM CHROME.EXE")
        chrome_options = webdriver.ChromeOptions()
        chrome_options.add_experimental_option("excludeSwitches", ['enable-automation'])
        chrome_options.add_argument(r'user-data-dir=C:\Users\xxxxx\AppData\Local\Google\Chrome\User Data')
        driver = webdriver.Chrome(ChromeDriverManager().install(), options=chrome_options)

        try:
            driver.get('https://web.whatsapp.com/')
            time.sleep(30)
            name = name
            msg = msg

            time.sleep(10)

            user = driver.find_element_by_xpath('//span[@title = "{}"]'.format(name))
            user.click()

            msg_box = driver.find_element_by_xpath('//div[@class="_3uMse"]')
            for part in msg.split('\n'):
                #msg_box.send_keys(part)
                print(part)
                ActionChains(driver).send_keys(part).perform()
                ActionChains(driver).key_down(Keys.SHIFT).key_down(Keys.ENTER).key_up(Keys.SHIFT).key_up(Keys.ENTER).perform()
            #ActionChains(driver).send_keys(Keys.RETURN).perform()

            time.sleep(randint(5, 10))
            button = driver.find_element_by_xpath('//button[@class="_1U1xa"]')
            button.click()

            time.sleep(5)
            driver.quit()
            run = True
        except Exception as e:
            print("Failed " + str(e))
            driver.quit()
            continue
    except Exception as e:
        print("Failed " + str(e))
        continue
我的错误消息如下

[WDM] - Current google-chrome version is 86.0.4240
INFO:WDM:Current google-chrome version is 86.0.4240
[WDM] - Get LATEST driver version for 86.0.4240
INFO:WDM:Get LATEST driver version for 86.0.4240
[WDM] - Driver [C:\Users\Administrator\.wdm\drivers\chromedriver\win32\86.0.4240.22\chromedriver.exe] found in cache
INFO:WDM:Driver [C:\Users\Administrator\.wdm\drivers\chromedriver\win32\86.0.4240.22\chromedriver.exe] found in cache
 
Failed Message: session not created
from chrome not reachable
  (Session info: chrome=86.0.4240.111)

SUCCESS: The process "chrome.exe" with PID 4124 has been terminated.
SUCCESS: The process "chrome.exe" with PID 4940 has been terminated.
SUCCESS: The process "chrome.exe" with PID 2688 has been terminated.
SUCCESS: The process "chrome.exe" with PID 6424 has been terminated.
SUCCESS: The process "chrome.exe" with PID 4092 has been terminated.
SUCCESS: The process "chrome.exe" with PID 6856 has been terminated.
SUCCESS: The process "chrome.exe" with PID 1756 has been terminated.
[WDM] - Current google-chrome version is 86.0.4240
INFO:WDM:Current google-chrome version is 86.0.4240
[WDM] - Get LATEST driver version for 86.0.4240
INFO:WDM:Get LATEST driver version for 86.0.4240
 
[WDM] - Driver [C:\Users\Administrator\.wdm\drivers\chromedriver\win32\86.0.4240.22\chromedriver.exe] found in cache
INFO:WDM:Driver [C:\Users\Administrator\.wdm\drivers\chromedriver\win32\86.0.4240.22\chromedriver.exe] found in cache
2020-10-30 07:59:00.056340
2020-10-30 07:59:00.237358
Failed Message: chrome not reachable
  (Session info: chrome=86.0.4240.111)