Issue installing extension with Selenium remote Firefox webdriver in Saucelabs

谁说我不能喝 提交于 2019-12-06 12:33:14
Jerry

Posted a bug report to SeleniumHQ and received this response, which fixed the above code.

In the RemoteWebDriver case for .NET, you need to use the ToBase64String() method. This should resolve the issue. Note that this is one of the reasons that other drivers have type-safe options classes instead of passing raw capabilities. Future versions of the .NET bindings should extend this pattern to Firefox as well, removing this as an issue in the future.

The GetRemoteDriver method from above should be updated to this.

private static IWebDriver GetRemoteDriver()
{
    var capabilities = new DesiredCapabilities();

    var profile = CreateFirefoxProfile();

    // Note the change here, calling .ToBase64String()
    capabilities.SetCapability(FirefoxDriver.ProfileCapabilityName, profile.ToBase64String());

    capabilities.SetCapability("name", buildContext);
    capabilities.SetCapability(CapabilityType.BrowserName,"firefox");
    capabilities.SetCapability(CapabilityType.Version,"");
    capabilities.SetCapability(CapabilityType.Platform, "Windows 10");
    capabilities.SetCapability("screen-resolution", "1280x1024");
    capabilities.SetCapability("username", "SaucelabsUserName");
    capabilities.SetCapability("accessKey", "SaucelabsAccessKey");
    capabilities.SetCapability("build", "BuildNumber");

    return new RemoteWebDriver(new Uri("http://ondemand.saucelabs.com/wd/hub"), capabilities);
}

After seeing what the fix is, I was able to find additional resources that mentioned this change.

https://stackoverflow.com/a/14285902/276681
https://code.google.com/p/selenium/issues/detail?id=2696#c4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!