![](/img/trans.png)
[英]An unhandled exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll Additional information: Unexpected error. Unknown error
[英]OpenQA.Selenium.WebDriverException: 'Unexpected server error.' using EdgeOptions
我正在嘗試使用帶有C#的Selenium WebDriver的W3C規范來運行測試。 這是我的代碼,根據閱讀這里的W3C文檔,我認為它是正確的。
[Test]
public void SimpleSelenium4Example()
{
//TODO please supply your Sauce Labs user name in an environment variable
var sauceUserName = Environment.GetEnvironmentVariable("SAUCE_USERNAME", EnvironmentVariableTarget.User);
//TODO please supply your own Sauce Labs access Key in an environment variable
var sauceAccessKey = Environment.GetEnvironmentVariable("SAUCE_ACCESS_KEY", EnvironmentVariableTarget.User);
var options = new EdgeOptions()
{
BrowserVersion = "latest",
PlatformName = "Windows 10"
};
var sauceOptions = new JObject
{
["username"] = sauceUserName,
["accessKey"] = sauceAccessKey,
["name"] = TestContext.CurrentContext.Test.Name
};
options.AddAdditionalCapability("sauce:options", sauceOptions.ToString());
Driver = new RemoteWebDriver(new Uri("http://ondemand.saucelabs.com:80/wd/hub"), options.ToCapabilities(),
TimeSpan.FromSeconds(600));
Driver.Navigate().GoToUrl("https://www.google.com");
Assert.Pass();
}
我收到此錯誤OpenQA.Selenium.WebDriverException:'意外的服務器錯誤。 實例化RemoteWebDriver時。
不確定是什么問題。 任何幫助表示贊賞。
.NET綁定適當地序列化了對象。 根本不需要嘗試使用Json.NET API(就像使用JObject
所暗示的那樣),並且在通過有線傳輸傳輸之前將JSON對象序列化(使用ToString()
)是可能的。
[Test]
public void SimpleSelenium4Example()
{
//TODO please supply your Sauce Labs user name in an environment variable
var sauceUserName = Environment.GetEnvironmentVariable("SAUCE_USERNAME", EnvironmentVariableTarget.User);
//TODO please supply your own Sauce Labs access Key in an environment variable
var sauceAccessKey = Environment.GetEnvironmentVariable("SAUCE_ACCESS_KEY", EnvironmentVariableTarget.User);
var options = new EdgeOptions()
{
BrowserVersion = "latest",
PlatformName = "Windows 10"
};
var sauceOptions = new Dictionary<string, object>();
sauceOptions["username"] = sauceUserName;
sauceOptions["accessKey"] = sauceAccessKey;
sauceOptions["name"] = TestContext.CurrentContext.Test.Name;
options.AddAdditionalCapability("sauce:options", sauceOptions);
Driver = new RemoteWebDriver(new Uri("http://ondemand.saucelabs.com:80/wd/hub"), options.ToCapabilities(),
TimeSpan.FromSeconds(600));
Driver.Navigate().GoToUrl("https://www.google.com");
Assert.Pass();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.