Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions dotnet/src/webdriver/Alert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public string? Text
{
get
{
Response commandResponse = this.driver.InternalExecute(DriverCommand.GetAlertText, null);
Response commandResponse = this.driver.Execute(DriverCommand.GetAlertText, null);
return (string?)commandResponse.Value;
}
}
Expand All @@ -57,15 +57,15 @@ public string? Text
/// </summary>
public void Dismiss()
{
this.driver.InternalExecute(DriverCommand.DismissAlert, null);
this.driver.Execute(DriverCommand.DismissAlert, null);
}

/// <summary>
/// Accepts the alert.
/// </summary>
public void Accept()
{
this.driver.InternalExecute(DriverCommand.AcceptAlert, null);
this.driver.Execute(DriverCommand.AcceptAlert, null);
}

/// <summary>
Expand All @@ -83,7 +83,7 @@ public void SendKeys(string keysToSend)
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("text", keysToSend);

this.driver.InternalExecute(DriverCommand.SetAlertValue, parameters);
this.driver.Execute(DriverCommand.SetAlertValue, parameters);
}
}
}
10 changes: 5 additions & 5 deletions dotnet/src/webdriver/CookieJar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public ReadOnlyCollection<Cookie> AllCookies
{
get
{
Response response = driver.InternalExecute(DriverCommand.GetAllCookies, new Dictionary<string, object>());
Response response = driver.Execute(DriverCommand.GetAllCookies, new Dictionary<string, object>());

List<Cookie> toReturn = new List<Cookie>();
if (response.Value is object?[] cookies)
Expand Down Expand Up @@ -67,7 +67,7 @@ public void AddCookie(Cookie cookie)

Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("cookie", cookie);
driver.InternalExecute(DriverCommand.AddCookie, parameters);
driver.Execute(DriverCommand.AddCookie, parameters);
}

/// <summary>
Expand All @@ -84,7 +84,7 @@ public void DeleteCookieNamed(string name)

Dictionary<string, object> parameters = new() { { "name", name } };

driver.InternalExecute(DriverCommand.DeleteCookie, parameters);
driver.Execute(DriverCommand.DeleteCookie, parameters);
}

/// <summary>
Expand All @@ -107,7 +107,7 @@ public void DeleteCookie(Cookie cookie)
/// </summary>
public void DeleteAllCookies()
{
driver.InternalExecute(DriverCommand.DeleteAllCookies, null);
driver.Execute(DriverCommand.DeleteAllCookies, null);
}

/// <summary>
Expand All @@ -125,7 +125,7 @@ public void DeleteAllCookies()

try
{
var rawCookie = driver.InternalExecute(DriverCommand.GetCookie, new() { { "name", name } }).Value;
var rawCookie = driver.Execute(DriverCommand.GetCookie, new() { { "name", name } }).Value;

return Cookie.FromDictionary((Dictionary<string, object>)rawCookie!);
}
Expand Down
5 changes: 3 additions & 2 deletions dotnet/src/webdriver/HttpCommandInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ public class HttpCommandInfo : CommandInfo
/// </summary>
/// <param name="method">Method of the Command</param>
/// <param name="resourcePath">Relative URL path to the resource used to execute the command</param>
/// <exception cref="ArgumentNullException">If <paramref name="method"/> or <paramref name="resourcePath"/> are <see langword="null"/>.</exception>
public HttpCommandInfo(string method, string resourcePath)
{
this.ResourcePath = resourcePath;
this.Method = method;
this.ResourcePath = resourcePath ?? throw new ArgumentNullException(nameof(resourcePath));
this.Method = method ?? throw new ArgumentNullException(nameof(method));
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions dotnet/src/webdriver/Logs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public ReadOnlyCollection<string> AvailableLogTypes
List<string> availableLogTypes = new List<string>();
try
{
Response commandResponse = this.driver.InternalExecute(DriverCommand.GetAvailableLogTypes, null);
Response commandResponse = this.driver.Execute(DriverCommand.GetAvailableLogTypes, null);
if (commandResponse.Value is object[] responseValue)
{
foreach (object logKind in responseValue)
Expand Down Expand Up @@ -88,7 +88,7 @@ public ReadOnlyCollection<LogEntry> GetLog(string logKind)

Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("type", logKind);
Response commandResponse = this.driver.InternalExecute(DriverCommand.GetLog, parameters);
Response commandResponse = this.driver.Execute(DriverCommand.GetLog, parameters);

if (commandResponse.Value is object?[] responseValue)
{
Expand Down
8 changes: 4 additions & 4 deletions dotnet/src/webdriver/Navigator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void Back()
/// <returns>A task object representing the asynchronous operation.</returns>
public async Task BackAsync()
{
await this.driver.InternalExecuteAsync(DriverCommand.GoBack, null).ConfigureAwait(false);
await this.driver.ExecuteAsync(DriverCommand.GoBack, null).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -79,7 +79,7 @@ public void Forward()
/// <returns>A task object representing the asynchronous operation.</returns>
public async Task ForwardAsync()
{
await this.driver.InternalExecuteAsync(DriverCommand.GoForward, null).ConfigureAwait(false);
await this.driver.ExecuteAsync(DriverCommand.GoForward, null).ConfigureAwait(false);
}

/// <summary>
Expand Down Expand Up @@ -112,7 +112,7 @@ public async Task GoToUrlAsync(string url)
{
{ "url", url }
};
await this.driver.InternalExecuteAsync(DriverCommand.Get, parameters).ConfigureAwait(false);
await this.driver.ExecuteAsync(DriverCommand.Get, parameters).ConfigureAwait(false);
}

/// <summary>
Expand Down Expand Up @@ -162,7 +162,7 @@ public void Refresh()
public async Task RefreshAsync()
{
// driver.SwitchTo().DefaultContent();
await this.driver.InternalExecuteAsync(DriverCommand.Refresh, null).ConfigureAwait(false);
await this.driver.ExecuteAsync(DriverCommand.Refresh, null).ConfigureAwait(false);
}
}
}
4 changes: 2 additions & 2 deletions dotnet/src/webdriver/ShadowRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public IWebElement FindElement(By by)
parameters.Add("using", by.Mechanism);
parameters.Add("value", by.Criteria);

Response commandResponse = this.driver.InternalExecute(DriverCommand.FindShadowChildElement, parameters);
Response commandResponse = this.driver.Execute(DriverCommand.FindShadowChildElement, parameters);
return this.driver.GetElementFromResponse(commandResponse);
}

Expand All @@ -122,7 +122,7 @@ public ReadOnlyCollection<IWebElement> FindElements(By by)
parameters.Add("using", by.Mechanism);
parameters.Add("value", by.Criteria);

Response commandResponse = this.driver.InternalExecute(DriverCommand.FindShadowChildElements, parameters);
Response commandResponse = this.driver.Execute(DriverCommand.FindShadowChildElements, parameters);
return this.driver.GetElementsFromResponse(commandResponse);
}

Expand Down
16 changes: 8 additions & 8 deletions dotnet/src/webdriver/TargetLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public IWebDriver Frame(int frameIndex)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("id", frameIndex);
this.driver.InternalExecute(DriverCommand.SwitchToFrame, parameters);
this.driver.Execute(DriverCommand.SwitchToFrame, parameters);
return this.driver;
}

Expand Down Expand Up @@ -116,7 +116,7 @@ public IWebDriver Frame(IWebElement frameElement)

Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("id", elementDictionary);
this.driver.InternalExecute(DriverCommand.SwitchToFrame, parameters);
this.driver.Execute(DriverCommand.SwitchToFrame, parameters);
return this.driver;
}

Expand All @@ -127,7 +127,7 @@ public IWebDriver Frame(IWebElement frameElement)
public IWebDriver ParentFrame()
{
Dictionary<string, object> parameters = new Dictionary<string, object>();
this.driver.InternalExecute(DriverCommand.SwitchToParentFrame, parameters);
this.driver.Execute(DriverCommand.SwitchToParentFrame, parameters);
return this.driver;
}

Expand All @@ -148,7 +148,7 @@ public IWebDriver Window(string windowHandleOrName)
parameters.Add("handle", windowHandleOrName);
try
{
this.driver.InternalExecute(DriverCommand.SwitchToWindow, parameters);
this.driver.Execute(DriverCommand.SwitchToWindow, parameters);
return this.driver;
}
catch (NoSuchWindowException)
Expand Down Expand Up @@ -195,7 +195,7 @@ public IWebDriver NewWindow(WindowType typeHint)
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("type", typeHint.ToString().ToLowerInvariant());

Response response = this.driver.InternalExecute(DriverCommand.NewWindow, parameters);
Response response = this.driver.Execute(DriverCommand.NewWindow, parameters);

Dictionary<string, object> result = (Dictionary<string, object>)response.Value!;
string newWindowHandle = result["handle"].ToString()!;
Expand All @@ -212,7 +212,7 @@ public IWebDriver DefaultContent()
{
Dictionary<string, object?> parameters = new Dictionary<string, object?>();
parameters.Add("id", null);
this.driver.InternalExecute(DriverCommand.SwitchToFrame, parameters);
this.driver.Execute(DriverCommand.SwitchToFrame, parameters);
return this.driver;
}

Expand All @@ -222,7 +222,7 @@ public IWebDriver DefaultContent()
/// <returns>Element that is active</returns>
public IWebElement ActiveElement()
{
Response response = this.driver.InternalExecute(DriverCommand.GetActiveElement, null);
Response response = this.driver.Execute(DriverCommand.GetActiveElement, null);
return this.driver.GetElementFromResponse(response);
}

Expand All @@ -234,7 +234,7 @@ public IAlert Alert()
{
// N.B. We only execute the GetAlertText command to be able to throw
// a NoAlertPresentException if there is no alert found.
this.driver.InternalExecute(DriverCommand.GetAlertText, null);
this.driver.Execute(DriverCommand.GetAlertText, null);
return new Alert(this.driver);
}
}
Expand Down
4 changes: 2 additions & 2 deletions dotnet/src/webdriver/Timeouts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public TimeSpan PageLoad

private TimeSpan ExecuteGetTimeout(string timeoutType)
{
Response commandResponse = this.driver.InternalExecute(DriverCommand.GetTimeouts, null);
Response commandResponse = this.driver.Execute(DriverCommand.GetTimeouts, null);

Dictionary<string, object?> responseValue = (Dictionary<string, object?>)commandResponse.Value!;
if (!responseValue.TryGetValue(timeoutType, out object? timeout))
Expand Down Expand Up @@ -144,7 +144,7 @@ private void ExecuteSetTimeout(string timeoutType, TimeSpan timeToWait)
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add(timeoutType, Convert.ToInt64(milliseconds));

this.driver.InternalExecute(DriverCommand.SetTimeouts, parameters);
this.driver.Execute(DriverCommand.SetTimeouts, parameters);
}
}
}
27 changes: 2 additions & 25 deletions dotnet/src/webdriver/WebDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -576,36 +576,13 @@ internal ReadOnlyCollection<IWebElement> GetElementsFromResponse(Response respon
return toReturn.AsReadOnly();
}

/// <summary>
/// Executes commands with the driver
/// </summary>
/// <param name="driverCommandToExecute">Command that needs executing</param>
/// <param name="parameters">Parameters needed for the command</param>
/// <returns>WebDriver Response</returns>
internal Response InternalExecute(string driverCommandToExecute, Dictionary<string, object> parameters)
{
return Task.Run(() => this.InternalExecuteAsync(driverCommandToExecute, parameters)).GetAwaiter().GetResult();
}

/// <summary>
/// Executes commands with the driver asynchronously
/// </summary>
/// <param name="driverCommandToExecute">Command that needs executing</param>
/// <param name="parameters">Parameters needed for the command</param>
/// <returns>A task object representing the asynchronous operation</returns>
internal Task<Response> InternalExecuteAsync(string driverCommandToExecute,
Dictionary<string, object> parameters)
{
return this.ExecuteAsync(driverCommandToExecute, parameters);
}

/// <summary>
/// Executes a command with this driver.
/// </summary>
/// <param name="driverCommandToExecute">A <see cref="DriverCommand"/> value representing the command to execute.</param>
/// <param name="parameters">A <see cref="Dictionary{K, V}"/> containing the names and values of the parameters of the command.</param>
/// <returns>A <see cref="Response"/> containing information about the success or failure of the command and any data returned by the command.</returns>
protected virtual Response Execute(string driverCommandToExecute,
protected internal virtual Response Execute(string driverCommandToExecute,
Dictionary<string, object> parameters)
{
return Task.Run(() => this.ExecuteAsync(driverCommandToExecute, parameters)).GetAwaiter().GetResult();
Expand All @@ -617,7 +594,7 @@ protected virtual Response Execute(string driverCommandToExecute,
/// <param name="driverCommandToExecute">A <see cref="DriverCommand"/> value representing the command to execute.</param>
/// <param name="parameters">A <see cref="Dictionary{K, V}"/> containing the names and values of the parameters of the command.</param>
/// <returns>A <see cref="Response"/> containing information about the success or failure of the command and any data returned by the command.</returns>
protected virtual async Task<Response> ExecuteAsync(string driverCommandToExecute, Dictionary<string, object> parameters)
protected internal virtual async Task<Response> ExecuteAsync(string driverCommandToExecute, Dictionary<string, object> parameters)
{
Command commandToExecute = new Command(SessionId, driverCommandToExecute, parameters);

Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/WebElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ Dictionary<string, object> IWebDriverObjectReference.ToDictionary()
/// <returns>The <see cref="Response"/> object containing the result of the command execution.</returns>
protected virtual Response Execute(string commandToExecute, Dictionary<string, object> parameters)
{
return this.driver.InternalExecute(commandToExecute, parameters);
return this.driver.Execute(commandToExecute, parameters);
}

private static string GetAtom(string atomResourceName)
Expand Down
14 changes: 7 additions & 7 deletions dotnet/src/webdriver/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public Point Position
{
get
{
Response commandResponse = this.driver.InternalExecute(DriverCommand.GetWindowRect, null);
Response commandResponse = this.driver.Execute(DriverCommand.GetWindowRect, null);

Dictionary<string, object?> rawPosition = (Dictionary<string, object?>)commandResponse.Value!;
int x = Convert.ToInt32(rawPosition["x"], CultureInfo.InvariantCulture);
Expand All @@ -64,7 +64,7 @@ public Point Position
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("x", value.X);
parameters.Add("y", value.Y);
this.driver.InternalExecute(DriverCommand.SetWindowRect, parameters);
this.driver.Execute(DriverCommand.SetWindowRect, parameters);
}
}

Expand All @@ -76,7 +76,7 @@ public Size Size
{
get
{
Response commandResponse = this.driver.InternalExecute(DriverCommand.GetWindowRect, null);
Response commandResponse = this.driver.Execute(DriverCommand.GetWindowRect, null);

Dictionary<string, object?> rawPosition = (Dictionary<string, object?>)commandResponse.Value!;
int height = Convert.ToInt32(rawPosition["height"], CultureInfo.InvariantCulture);
Expand All @@ -90,7 +90,7 @@ public Size Size
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("width", value.Width);
parameters.Add("height", value.Height);
this.driver.InternalExecute(DriverCommand.SetWindowRect, parameters);
this.driver.Execute(DriverCommand.SetWindowRect, parameters);
}
}

Expand All @@ -99,23 +99,23 @@ public Size Size
/// </summary>
public void Maximize()
{
this.driver.InternalExecute(DriverCommand.MaximizeWindow, null);
this.driver.Execute(DriverCommand.MaximizeWindow, null);
}

/// <summary>
/// Minimizes the current window if it is not already minimized.
/// </summary>
public void Minimize()
{
this.driver.InternalExecute(DriverCommand.MinimizeWindow, null);
this.driver.Execute(DriverCommand.MinimizeWindow, null);
}

/// <summary>
/// Sets the current window to full screen if it is not already in that state.
/// </summary>
public void FullScreen()
{
this.driver.InternalExecute(DriverCommand.FullScreenWindow, null);
this.driver.Execute(DriverCommand.FullScreenWindow, null);
}
}
}
Loading