selenium: PlatformNotSupportedException when using RemoteWebDriver in C# and .NET Core 2.0

Meta -

OS: Windows 10 Selenium Version: Selenium.WebDriver 3.6.0 C#, .NET Core 2.0 Browser: RemoteWebDriver –>

Browser Version: na

Expected Behavior -

Connects to RemoteWebDriver VM.

Actual Behavior - Throws this error:

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 MicroEdge.DonorCentral.Automation.Common.WebDriver.RemoteWebDriverConfiguration.CreateRemoteWebDriver() in C:\Users\Windows 10

Seems related to this error: https://github.com/Azure/azure-iot-sdk-csharp/issues/140

Steps to reproduce -

This is generic test that can reproduce this issue. Will require SL credentials to execute.

public class UnitTest1 { [Fact] public void Test1() { Uri bsuri = new Uri(“http://ondemand.saucelabs.com:80/wd/hub”); IWebDriver driver; DesiredCapabilities caps = new DesiredCapabilities(); caps.SetCapability(CapabilityType.BrowserName, “chrome”); caps.SetCapability(CapabilityType.Version, “49”); caps.SetCapability(CapabilityType.Platform, “Windows 7”); caps.SetCapability(“username”, “”); caps.SetCapability(“accessKey”, “”); caps.SetCapability(“name”, “testing”); driver = new RemoteWebDriver(bsuri, caps);

driver.Navigate().GoToUrl(“http://www.google.com”); Console.WriteLine(driver.Title); IWebElement query = driver.FindElement(By.Name(“q”)); query.SendKeys(“SauceLabs”); query.Submit(); Console.WriteLine(driver.Title);

driver.Quit(); } }

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 5
  • Comments: 21 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Sure…

In the RemoteWebDriver class, I added a IWebProxy param to one of the constructors public RemoteWebDriver(Uri remoteAddress, ICapabilities desiredCapabilities, TimeSpan commandTimeout, IWebProxy proxy = null) : this(new HttpCommandExecutor(remoteAddress, commandTimeout, proxy), desiredCapabilities) { }

I also added the IWebProxy Param to the HttpCommandExecutor and stored it locally public HttpCommandExecutor(Uri addressOfRemoteServer, TimeSpan timeout, IWebProxy proxy = null) : this(addressOfRemoteServer, timeout, true) { this.proxy = proxy; }

Then in the MakeHttpRequest method I assign the passed in WebProxy to the HttpWebRequest object

          'HttpWebRequest request = HttpWebRequest.Create(requestInfo.FullUri) as HttpWebRequest;
          if(this.proxy != null)
          {
              request.Proxy = this.proxy;
          }

…`

Then, when I create an instance of the RemoteWebDriver I simply pass in a custom proxy class - In my case the proxy just passes through the Uri as there is no proxy required, but you could also pass in any custom proxy that supports IWebProxy interface.

(for copmpleteness, this is my proxy class)

`public class PassThroughProxy : IWebProxy
{
    public ICredentials Credentials { get; set; }

    public Uri GetProxy(Uri destination)
    {
        return destination;
    }

    public bool IsBypassed(Uri host)
    {
        return false;
    }
}`

Cheers Tim.

This issue is fixed in 942b8a4.

@TimJarvis any chance you could share a snippet of that code? Cheers