【问题标题】:Error using Selenium Chrome Webdriver with python将 Selenium Chrome Webdriver 与 python 一起使用时出错
【发布时间】:2021-10-04 20:00:27
【问题描述】:

您好,我正在使用 chrome 驱动程序,但我无法修复此错误

我的代码:

options = Options()
        
        options.add_argument('--disable-gpu')
        options.add_argument('--disable-dev-shm-usage')
        self.site = webdriver.Chrome(executable_path="C:\chromedriver.exe",chrome_options=options)
        
        
        self.site.get("https://sgite.com/en/site/")

错误: [23468:14696:1004/232130.459:ERROR:chrome_browser_main_extra_parts_metrics.cc(228)] crbug.com/1216328:开始检查蓝牙可用性。如果没有报告结束,请报告。 [23468:14696:1004/232130.468:ERROR:chrome_browser_main_extra_parts_metrics.cc(231)] crbug.com/1216328:检查蓝牙可用性已结束。 [23468:14696:1004/232130.514:ERROR:chrome_browser_main_extra_parts_metrics.cc(234)] crbug.com/1216328:检查默认浏览器状态已启动。如果没有报告结束,请报告。 [23468:14696:1004/232130.588:ERROR:chrome_browser_main_extra_parts_metrics.cc(238)] crbug.com/1216328:检查默认浏览器状态已结束。

【问题讨论】:

  • 请将代码和错误以纯文本形式发布。图片链接只会让人们更难帮助您。
  • 抱歉编辑了

标签: python selenium-chromedriver


【解决方案1】:

如果您将 Selenium 与 Python 一起使用,则将这些额外选项添加到您的 Selenium 代码中-

options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(options=options)

【讨论】:

  • 如何在 JavaScript 上做同样的事情?
  • 你在哪里添加 webdriver 的路径。例如。 PATH="C:/browserDrivers/chromeDriver.exe" 我使用它并传入路径。你不需要那个吗?
  • @Dale 如果将chromedriver.exe 保留为C:\Windows\System32,则无需在python 代码中提及路径。
【解决方案2】:

同样的事情对我有用,就像我上面的答案一样。

options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(options=options)
driver.get('https://something.com/login')
driver.maximize_window()

【讨论】:

    【解决方案3】:

    对 Python 来说完全正确

    options = webdriver.ChromeOptions()
    options.add_experimental_option('excludeSwitches', ['enable-logging'])
    browser = webdriver.Chrome(options=options)
    

    【讨论】:

    • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
    【解决方案4】:

    下面的代码已经过测试,效果很好。

    options = webdriver.ChromeOptions()
    options.add_experimental_option('excludeSwitches', ['enable-logging'])
    driver = webdriver.Chrome(options=options)
    

    【讨论】:

      猜你喜欢
      • 2020-12-16
      • 1970-01-01
      • 2013-07-19
      • 2015-09-17
      • 2014-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-09
      相关资源
      最近更新 更多