提问人:Damo 提问时间:11/14/2023 最后编辑:Damo 更新时间:11/14/2023 访问量:60
使用 Azure Pipelines 时,更新 Visual Studio 测试平台以使用最新版本的 Edge 浏览器
Update Visual Studio test platform to use latest version of Edge browser when using Azure Pipelines
问:
我正在设置一个 Azure DEVOPS 管道来运行自动化 UI 测试。除了一个细节之外,这基本上是成功的。
Azure Pipelines VM/代理没有最新的 MS Edge Web 浏览器版本可用。
我们的 IT 策略要求我们始终运行最新版本的 Edge,因此我必须在我的开发计算机上运行最新版本。这意味着我必须在项目中安装最新版本的“Selenium.WebDriver.MSEdgeDriver”。
在本地,所有测试都运行良好。
当我使用最新的 Selenium.WebDriver.MSEdgeDriver 运行该版本时,出现错误:
System.InvalidOperationException : session not created: This version of Microsoft Edge WebDriver only supports Microsoft Edge version 119 Current browser version is 118.0.2088.76 with binary path C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe (SessionNotCreated)
我在本地运行 Edge 119.0.2151.42。
我在项目中将 Selenium.WebDriver.MSEdgeDriver 降级到 118.0.2088.76,现在我的 DEVOPS 测试在 Azure Pipelines 代理/VM 上按预期运行,但当然,我无法再在本地运行或调试测试。
发布管道中是否有方法可以升级边缘?
我知道我可以创建一个专用的 VM 并改用它,但是当该功能原生存在于 Azure 中时,这似乎是一种浪费。
还有别的办法,我错过了什么吗?
答:
不确定您如何管理浏览器驱动程序,但我猜您正在手动设置路径。edgedriver.exe
如果这是真的,为什么不让 selenium 根据您系统上的 Edge 浏览器来决定它应该使用哪个。这样,它将使用 Azure VM 中的 Edge 驱动程序和本地系统中的 Edge 驱动程序。EdgeDriver
118
119
为了实现上述目标,您只需要确保使用的是最新的硒(或更高)。如果可能,请使用 latest()。v4.6.0
v4.15
您无需设置 的路径/位置。代码可以像下面这样简单。driver.exe
Python 代码:
from selenium import webdriver
driver = webdriver.Edge()
driver.get("https://stackoverflow.com/")
driver.quit()
Java 代码:
WebDriver driver = new EdgeDriver();
driver.get("https://stackoverflow.com/");
driver.quit();
C# 代码:
IWebDriver driver = new EdgeDriver();
driver.Navigate().GoToUrl("https://stackoverflow.com/");
driver.Quit();
要了解有关 Selenium Manager 的更多信息,请参阅以下链接:
- https://stackoverflow.com/a/76574264/7598774
- https://stackoverflow.com/a/76463081/7598774
- Selenium 管理器
评论