我已经更新了 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_init
在 BluetoothAdapterWinrt::OnGetDefaultAdapter()
中失败.
...implies that ScopedClosureRunner on_init
failed in BluetoothAdapterWinrt::OnGetDefaultAdapter()
.
此错误定义在 bluetooth_adapter_winrt.cc 如下:
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;
}
确保:
但据观察,可以通过以 root
用户(administrator
)身份运行 Chrome 来抑制此错误在 Linux 上.但这与 ChromeDriver 中的文档有偏差- 用于 Chrome 的 WebDriver 提到它的地方:
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.虽然可以通过在创建 WebDriver 会话,即 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.
最后,根据 Selenium Chrome 驱动程序:解决有关注册表项和实验选项的错误消息可以通过添加参数来抑制这些错误日志:
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:WebDriverschromedriver.exe')
driver.get("https://www.google.com/")
这篇关于如何在启动 Chrome 并尝试使用 Selenium 使用 ChromeDriver 访问网页时解决“获取默认适配器失败"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!