python+selenium自动化,没有写close和quit,浏览器窗口会自动关闭解决方案

python+selenium自动化,没有写close和quit,浏览器窗口会自动关闭解决方案

#增加参数
option.add_experimental_option("detach", True)

例如:

  #加启动配置
    option = webdriver.ChromeOptions()
    #关闭“chrome正受到自动测试软件的控制”
    #V75以及以下版本
    #option.add_argument('disable-infobars')
    #V76以及以上版本
    option.add_experimental_option('useAutomationExtension', False)
    option.add_experimental_option('excludeSwitches', ['enable-automation'])
    #不自动关闭浏览器
    option.add_experimental_option("detach", True)
    # 打开chrome浏览器
    driver = webdriver.Chrome(chrome_options=option)
    return driver
chrome正受到自动测试软件的控制
原文地址:https://www.cnblogs.com/lizm166/p/13180924.html