启动Chrome时如何解决“获取默认适配器失败"错误,并尝试通过使用Selenium的ChromeDriver访问网页 [英] How to solve 'Getting Default Adapter failed' error when launching Chrome and try to access a webpage using the ChromeDriver using Selenium

查看:2208
本文介绍了启动Chrome时如何解决“获取默认适配器失败"错误,并尝试通过使用Selenium的ChromeDriver访问网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经更新了Selenium,但是即使加载了网页,该错误仍然会继续发生.但是,在某些情况下,驱动程序会启动,但停滞不前.这是否引起了问题?如果是,该如何解决?

I have updated Selenium but the error keeps occurring even though the web page loads. However, in some instances, the driver starts but it is stagnant. Is this causing an issue and if so, how do I resolve it?

[11556:9032:0502/152954.314:ERROR:device_event_log_impl.cc(162)] [15:29:54.314] Bluetooth: bluetooth_adapter_winrt.cc:1055 Getting Default Adapter failed.

推荐答案

此错误消息...

ERROR:device_event_log_impl.cc(162)] [15:29:54.314] Bluetooth: bluetooth_adapter_winrt.cc:1055 Getting Default Adapter failed.

...表示ScopedClosureRunner on_initBluetoothAdapterWinrt::OnGetDefaultAdapter()中失败.

...implies that ScopedClosureRunner on_init failed in BluetoothAdapterWinrt::OnGetDefaultAdapter().

此错误在 bluetooth_adapter_winrt.cc 中定义a>如下:

This error is defined in bluetooth_adapter_winrt.cc as follows:

void BluetoothAdapterWinrt::OnGetDefaultAdapter(
    base::ScopedClosureRunner on_init,
    ComPtr<IBluetoothAdapter> adapter) {
  DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
  if (!adapter) {
    BLUETOOTH_LOG(ERROR) << "Getting Default Adapter failed.";
    return;
  }


解决方案

确保:


Solution

Ensure that:

  • Selenium is upgraded to current levels Version 3.141.59.
  • ChromeDriver is updated to current ChromeDriver v84.0 level.
  • Chrome is updated to current Chrome Version 84.0 level. (as per ChromeDriver v84.0 release notes)
  • If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.

但是据观察,通过在Linux上以 root 用户( administrator )运行Chrome,可以消除此错误.但这可能与 ChromeDriver中的文档有所不同-提到的WebDriver for Chrome :

However it was observed that this error can be supressed by running Chrome as root user (administrator) on Linux. but that would be a deviation from the documentation in ChromeDriver - WebDriver for Chrome where it is mentioned:

Chrome在启动过程中崩溃的常见原因是在Linux上以root用户(管理员)身份运行Chrome.虽然可以通过在创建您的 ChromeDriver 会话,因为这种配置不受支持并且不建议使用.

A common cause for Chrome to crash during startup is running Chrome as root user (administrator) on Linux. While it is possible to work around this issue by passing '--no-sandbox' flag when creating your WebDriver session, i.e. the ChromeDriver session as such a configuration is unsupported and highly discouraged.

理想情况下,您需要配置您的环境以改为以普通用户身份运行Chrome.

Ideally, you need to configure your environment to run Chrome as a regular user instead.

最后,按照

Finally, as per the documentation in Selenium Chrome Driver: Resolve Error Messages Regarding Registry Keys and Experimental Options these error logs can be supressed by adding the argument:

excludeSwitches: ['enable-logging']

因此,您的有效代码块将是:

So your effective code block will be:

from selenium import webdriver

options = webdriver.ChromeOptions() 
options.add_experimental_option("excludeSwitches", ["enable-logging"])
driver = webdriver.Chrome(options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
driver.get("https://www.google.com/")

这篇关于启动Chrome时如何解决“获取默认适配器失败"错误,并尝试通过使用Selenium的ChromeDriver访问网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆