Skip to content

Commit

Permalink
Rearranging some .NET code
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed Dec 6, 2020
1 parent a530271 commit fa6e369
Showing 1 changed file with 39 additions and 42 deletions.
81 changes: 39 additions & 42 deletions dotnet/src/webdriver/Remote/RemoteWebDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,36 @@ public object ExecuteAsyncScript(string script, params object[] args)
return this.ExecuteScriptCommand(script, DriverCommand.ExecuteAsyncScript, args);
}

/// <summary>
/// Finds an element matching the given mechanism and value.
/// </summary>
/// <param name="mechanism">The mechanism by which to find the element.</param>
/// <param name="value">The value to use to search for the element.</param>
/// <returns>The first <see cref="IWebElement"/> matching the given criteria.</returns>
public virtual IWebElement FindElement(string mechanism, string value)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("using", mechanism);
parameters.Add("value", value);
Response commandResponse = this.Execute(DriverCommand.FindElement, parameters);
return this.GetElementFromResponse(commandResponse);
}

/// <summary>
/// Finds all elements matching the given mechanism and value.
/// </summary>
/// <param name="mechanism">The mechanism by which to find the elements.</param>
/// <param name="value">The value to use to search for the elements.</param>
/// <returns>A collection of all of the <see cref="IWebElement">IWebElements</see> matching the given criteria.</returns>
public virtual ReadOnlyCollection<IWebElement> FindElements(string mechanism, string value)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("using", mechanism);
parameters.Add("value", value);
Response commandResponse = this.Execute(DriverCommand.FindElements, parameters);
return this.GetElementsFromResponse(commandResponse);
}

/// <summary>
/// Finds the first element in the page that matches the ID supplied
/// </summary>
Expand Down Expand Up @@ -800,47 +830,14 @@ public ReadOnlyCollection<IWebElement> FindElementsByCssSelector(string cssSelec
return this.FindElements("css selector", cssSelector);
}

/// <summary>
/// Finds an element matching the given mechanism and value.
/// </summary>
/// <param name="mechanism">The mechanism by which to find the element.</param>
/// <param name="value">The value to use to search for the element.</param>
/// <returns>The first <see cref="IWebElement"/> matching the given criteria.</returns>
public virtual IWebElement FindElement(string mechanism, string value)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("using", mechanism);
parameters.Add("value", value);
Response commandResponse = this.Execute(DriverCommand.FindElement, parameters);
return this.GetElementFromResponse(commandResponse);
}

/// <summary>
/// Finds all elements matching the given mechanism and value.
/// </summary>
/// <param name="mechanism">The mechanism by which to find the elements.</param>
/// <param name="value">The value to use to search for the elements.</param>
/// <returns>A collection of all of the <see cref="IWebElement">IWebElements</see> matching the given criteria.</returns>
public virtual ReadOnlyCollection<IWebElement> FindElements(string mechanism, string value)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("using", mechanism);
parameters.Add("value", value);
Response commandResponse = this.Execute(DriverCommand.FindElements, parameters);
return this.GetElementsFromResponse(commandResponse);
}

/// <summary>
/// Gets a <see cref="Screenshot"/> object representing the image of the page on the screen.
/// </summary>
/// <returns>A <see cref="Screenshot"/> object containing the image.</returns>
public Screenshot GetScreenshot()
{
// Get the screenshot as base64.
Response screenshotResponse = this.Execute(DriverCommand.Screenshot, null);
string base64 = screenshotResponse.Value.ToString();

// ... and convert it.
return new Screenshot(base64);
}

Expand All @@ -856,15 +853,6 @@ public PrintDocument Print(PrintOptions printOptions)
return new PrintDocument(base64);
}

/// <summary>
/// Dispose the RemoteWebDriver Instance
/// </summary>
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}

/// <summary>
/// Performs the specified list of actions with this action executor.
/// </summary>
Expand Down Expand Up @@ -895,6 +883,15 @@ public void ResetInputState()
this.Execute(DriverCommand.CancelActions, null);
}

/// <summary>
/// Dispose the RemoteWebDriver Instance
/// </summary>
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}

/// <summary>
/// Executes commands with the driver
/// </summary>
Expand Down

0 comments on commit fa6e369

Please sign in to comment.