gpt4 book ai didi

c# - .NET Core - Selenium RemoteWebDriver - PlatformNotSupportedException

转载 作者:行者123 更新时间:2023-11-30 21:37:37 29 4
gpt4 key购买 nike

我正在尝试使用 .net core 2xunit 运行 Selenium 测试

作为 Selenium 服务器,我使用 docker 容器,如下所述: https://github.com/SeleniumHQ/docker-selenium

使用命令运行容器:
docker run -d -p 4444:4444 -v/dev/shm:/dev/shm selenium/standalone-chrome

测试代码

public void Test()
{
IWebDriver driver = new RemoteWebDriver(new Uri("http://127.0.0.1:4444"), new ChromeOptions());
driver.Navigate().GoToUrl("https://www.google.com");
var s = ((ITakesScreenshot)driver).GetScreenshot();
s.SaveAsFile("screen.jpg");
}

当我尝试运行测试时出现异常:

System.PlatformNotSupportedException : Operation is not supported on this platform.
at System.Net.SystemWebProxy.GetProxy(Uri destination)
at System.Net.ServicePointManager.ProxyAddressIfNecessary(Uri& address, IWebProxy proxy)
at System.Net.ServicePointManager.FindServicePoint(Uri address, IWebProxy proxy)
at System.Net.HttpWebRequest.get_ServicePoint()
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at Automation.LoginTests.Test() in C:\Git\Automation\test\Tests\LoginTests.cs:line 29

当我在 linux (Debian 9) 或 Windows 10 上运行时,结果相同。难道我做错了什么? Selenium 似乎可以支持.NET Core 2

最佳答案

感谢 this comment 在 github 上发现了一个问题.

https://github.com/SeleniumHQ/selenium/issues/4770

此处描述了工作代码的解决方法: https://github.com/SeleniumHQ/selenium/issues/4770#issuecomment-337370420

关于c# - .NET Core - Selenium RemoteWebDriver - PlatformNotSupportedException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47061674/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com