C# .NET核心-Selenium RemoteWebDriver-PlatformNotSupportedException
我正在尝试使用C# .NET核心-Selenium RemoteWebDriver-PlatformNotSupportedException,c#,.net,selenium,.net-core,C#,.net,Selenium,.net Core,我正在尝试使用.netcore2和xunit 作为Selenium服务器,我使用docker容器,如下所述: 正在使用命令运行容器: 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 Chr
.netcore2
和xunit
作为Selenium服务器,我使用docker容器,如下所述:
正在使用命令运行容器: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在github上发现了一个问题,这多亏了 下面介绍了使用工作代码的变通方法:
似乎是.NET的核心问题。他们还没有实现此方法,这需要修改Selenium C#绑定,使其从stacktrace开始工作。看起来它无法检测平台定义的代理。尝试禁用检测:
WebRequest.DefaultWebProxy=null代码>我做了更改,但得到了相同的错误。能否添加有关构建Webdriver.NET解决方案的更多详细信息?