問題描述
我已經更新了 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;
}
解決方案
確保:
- Selenium 已升級到當前級別版本 3.141.59.
- ChromeDriver 已更新為當前 ChromeDriverv84.0 級別.
- Chrome 已更新至當前 Chrome 版本 84.0 級別.(根據 ChromeDriver v84.0 發行說明)
- 如果您的基本 Web 客戶端 版本太舊,請卸載它并安裝最新的 GA 和發布版本的 Web 客戶端.
- 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.
但據觀察,可以通過以 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模板網!