Selenium Edge Python 错误在测试执行后自动关闭 Edge 浏览器

问题描述 投票:0回答:4

我正在尝试测试 selenium 以获取自动登录网站的解决方案,但我什至无法让 Selenium 保持打开状态。它执行现在应该执行的操作,然后在没有 driver.quit() 的情况下立即退出。 我收到以下错误,我想了解它们的含义:

DevTools listening on ws://127.0.0.1:51111/devtools/browser/111111fe-423z-111zz-1116-r0z2300086f7
[3420:22152:1110/151643.950:ERROR:edge_auth_errors.cc(387)] EDGE_IDENTITY: Get Default OS Account failed: Error: Primary Error: kImplicitSignInFailure, Secondary Error: kAccountProviderFetchError, Platform error: 0, Error string:  

[3420:22152:1110/151644.757:ERROR:fallback_task_provider.cc(119)] Every renderer should have at least one task provided by a primary task provider. If a fallback task is shown, it is a bug. Please file a new bug and tag it as a dependency of crbug.com/739782.
[3420:22152:1110/151647.899:ERROR:fallback_task_provider.cc(119)] Every renderer should have at least one task provided by a primary task provider. If a fallback task is shown, it is a bug. Please file a new bug and tag it as a dependency of crbug.com/739782.
Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos
https://www.yahoo.com/

这是我的代码:

from selenium import webdriver
from selenium.webdriver.edge.service import Service

ser = Service("C:\\Users\\Desktop\\Projects\\auto_login\\msedgedriver.exe")
driver = webdriver.Edge(service = ser)
driver.get("http://yahoo.com")
print(driver.title)
print(driver.current_url)
python selenium selenium-webdriver microsoft-edge selenium-edgedriver
4个回答
3
投票

您看到的错误:

[3420:22152:1110/151643.950:ERROR:edge_auth_errors.cc(387)] EDGE_IDENTITY: Get Default OS Account failed: Error: Primary Error: kImplicitSignInFailure, Secondary Error: kAccountProviderFetchError, Platform error: 0, Error string:  

[3420:22152:1110/151644.757:ERROR:fallback_task_provider.cc(119)] Every renderer should have at least one task provided by a primary task provider. If a fallback task is shown, it is a bug. Please file a new bug and tag it as a dependency of crbug.com/739782.
[3420:22152:1110/151647.899:ERROR:fallback_task_provider.cc(119)] Every renderer should have at least one task provided by a primary task provider. If a fallback task is shown, it is a bug. Please file a new bug and tag it as a dependency of crbug.com/739782.

是由于 Chrome 产生了子进程和任务管理器兼容性而导致的一般错误的结果,您现在可以忽略它。有关详细信息,请检查问题 739782:[任务管理器] [元 bug ☂️] 任务管理器中未显示进程

此外,某些特定的Python框架往往会在程序的所有行都成功执行时自动关闭浏览器,例如Python-Unittest 与上面解释的错误没有关系。


3
投票

我发现以下代码将禁用“DevTools Listening on ...”错误(警告?)。

from selenium import webdriver
from selenium.webdriver.edge.options import Options as EdgeOptions

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

我正在使用 Selenium 4.5.0 和 Edge 驱动程序 Edge 版本 105。 它基本上与用于在 Chrome 驱动程序上禁用这些类型的消息的代码相同。


0
投票

我正在使用 Selenium 4.6 和用户代理随机

from selenium import webdriver
from selenium.webdriver.edge import service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from fake_useragent import UserAgent
import os
os.system("cls")



def User():
    
    ua = UserAgent()
    return ua.random


edgeOption = webdriver.EdgeOptions()
edgeOption.add_argument(f'user-agent={User()}')
edgeOption.add_argument("start-maximized")
s=service.Service(r'msedgedriver.exe')
driver = webdriver.Edge(service=s, options=edgeOption)
driver.get("http://whatsmyuseragent.org/")
WebDriverWait(driver, 10)

user = driver.find_element(By.XPATH, "//div[@class='intro-body']/div[@class='container']/div[@class='row']/div[@class='col-md-8 col-md-offset-2'][1]/div[@class='user-agent']/p[@class='intro-text']").text
ip = driver.find_element(By.XPATH, "//div[@class='intro-body']/div[@class='container']/div[@class='row']/div[@class='col-md-8 col-md-offset-2'][2]/div[@class='ip-address']/p[@class='intro-text']").text

print(user)
print(ip)

0
投票

也许有点晚了,但使用最新版本更新网络驱动程序解决了我的问题:

[19204:19348:0902/234717.979:ERROR:edge_auth_errors.cc(523)] EDGE_IDENTITY:获取默认操作系统帐户失败:错误:主要错误:kImplicitSignInFailure,次要错误:kAccountProviderFetchError,平台错误:0,错误字符串:

© www.soinside.com 2019 - 2024. All rights reserved.