Skip to content

Commit

Permalink
Throw more informative exception on invalid new session response in .NET
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed Sep 6, 2019
1 parent 87384d1 commit 5caa106
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion dotnet/src/webdriver/Remote/RemoteWebDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,13 @@ protected void StartSession(ICapabilities desiredCapabilities)

Response response = this.Execute(DriverCommand.NewSession, parameters);

Dictionary<string, object> rawCapabilities = (Dictionary<string, object>)response.Value;
Dictionary<string, object> rawCapabilities = response.Value as Dictionary<string, object>;
if (rawCapabilities == null)
{
string errorMessage = string.Format(CultureInfo.InvariantCulture, "The new session command returned a value ('{0}') that is not a valid JSON object.", response.Value);
throw new WebDriverException(errorMessage);
}

ReturnedCapabilities returnedCapabilities = new ReturnedCapabilities(rawCapabilities);
this.capabilities = returnedCapabilities;
this.sessionId = new SessionId(response.SessionId);
Expand Down

0 comments on commit 5caa106

Please sign in to comment.