简体   繁体   English

将 Selenium Chrome Webdriver 与 python 一起使用时出错

[英]Error using Selenium Chrome Webdriver with python

hi im using chrome driver but i cant fix this error您好,我正在使用 Chrome 驱动程序,但我无法修复此错误

mycode:我的代码:

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/")

error: [23468:14696:1004/232130.459:ERROR:chrome_browser_main_extra_parts_metrics.cc(228)] crbug.com/1216328: Checking Bluetooth availability started.错误:[23468:14696:1004/232130.459:ERROR:chrome_browser_main_extra_parts_metrics.cc(228)] crbug.com/1216328:开始检查蓝牙可用性。 Please report if there is no report that this ends.如果没有报告此结束,请报告。 [23468:14696:1004/232130.468:ERROR:chrome_browser_main_extra_parts_metrics.cc(231)] crbug.com/1216328: Checking Bluetooth availability ended. [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: Checking default browser status started. [23468:14696:1004/232130.514:ERROR:chrome_browser_main_extra_parts_metrics.cc(234)] crbug.com/1216328:开始检查默认浏览器状态。 Please report if there is no report that this ends.如果没有报告此结束,请报告。 [23468:14696:1004/232130.588:ERROR:chrome_browser_main_extra_parts_metrics.cc(238)] crbug.com/1216328: Checking default browser status ended. [23468:14696:1004/232130.588:ERROR:chrome_browser_main_extra_parts_metrics.cc(238)] crbug.com/1216328:检查默认浏览器状态已结束。

If you are using Selenium with Python then add these extra options into your Selenium code-如果您在 Python 中使用 Selenium,请将这些额外选项添加到您的 Selenium 代码中-

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

This same thing worked for me like the answer above me.同样的事情对我有用,就像我上面的答案一样。

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

Exactly" for Python正好”适用于 Python

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

Below code is the answer you want .Tested it and it's working like charm.下面的代码是您想要的答案。经过测试,它就像魅力一样工作。

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

happy Coding快乐编码

For the Javascript users, the solution is:对于Javascript用户,解决方法是:

const { Builder } = require('selenium-webdriver')
const chrome = require('selenium-webdriver/chrome')
const options = new chrome.Options()
options.excludeSwitches(['enable-logging'])
const driver = new Builder()
   .forBrowser('chrome')
   .setChromeOptions(options)
   .build()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM