diff --git a/dotnet/src/webdriver/Alert.cs b/dotnet/src/webdriver/Alert.cs index 2931eb39f68ee..fb32d3e0fb0c4 100644 --- a/dotnet/src/webdriver/Alert.cs +++ b/dotnet/src/webdriver/Alert.cs @@ -45,7 +45,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; } } @@ -55,7 +55,7 @@ public string? Text /// public void Dismiss() { - this.driver.InternalExecute(DriverCommand.DismissAlert, null); + this.driver.Execute(DriverCommand.DismissAlert, null); } /// @@ -63,7 +63,7 @@ public void Dismiss() /// public void Accept() { - this.driver.InternalExecute(DriverCommand.AcceptAlert, null); + this.driver.Execute(DriverCommand.AcceptAlert, null); } /// @@ -81,7 +81,7 @@ public void SendKeys(string keysToSend) Dictionary parameters = new Dictionary(); parameters.Add("text", keysToSend); - this.driver.InternalExecute(DriverCommand.SetAlertValue, parameters); + this.driver.Execute(DriverCommand.SetAlertValue, parameters); } } } diff --git a/dotnet/src/webdriver/CookieJar.cs b/dotnet/src/webdriver/CookieJar.cs index 0a8fa26895488..475fc8fdbd06c 100644 --- a/dotnet/src/webdriver/CookieJar.cs +++ b/dotnet/src/webdriver/CookieJar.cs @@ -32,7 +32,7 @@ public ReadOnlyCollection AllCookies { get { - Response response = driver.InternalExecute(DriverCommand.GetAllCookies, new Dictionary()); + Response response = driver.Execute(DriverCommand.GetAllCookies, new Dictionary()); List toReturn = new List(); if (response.Value is object?[] cookies) @@ -65,7 +65,7 @@ public void AddCookie(Cookie cookie) Dictionary parameters = new Dictionary(); parameters.Add("cookie", cookie); - driver.InternalExecute(DriverCommand.AddCookie, parameters); + driver.Execute(DriverCommand.AddCookie, parameters); } /// @@ -82,7 +82,7 @@ public void DeleteCookieNamed(string name) Dictionary parameters = new() { { "name", name } }; - driver.InternalExecute(DriverCommand.DeleteCookie, parameters); + driver.Execute(DriverCommand.DeleteCookie, parameters); } /// @@ -105,7 +105,7 @@ public void DeleteCookie(Cookie cookie) /// public void DeleteAllCookies() { - driver.InternalExecute(DriverCommand.DeleteAllCookies, null); + driver.Execute(DriverCommand.DeleteAllCookies, null); } /// @@ -123,7 +123,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)rawCookie!); } diff --git a/dotnet/src/webdriver/HttpCommandInfo.cs b/dotnet/src/webdriver/HttpCommandInfo.cs index ecca593ce55de..56c8beef152a8 100644 --- a/dotnet/src/webdriver/HttpCommandInfo.cs +++ b/dotnet/src/webdriver/HttpCommandInfo.cs @@ -49,10 +49,11 @@ public class HttpCommandInfo : CommandInfo /// /// Method of the Command /// Relative URL path to the resource used to execute the command + /// If or are . 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)); } /// diff --git a/dotnet/src/webdriver/Logs.cs b/dotnet/src/webdriver/Logs.cs index 3dcd6d43c607f..32157f20e56ed 100644 --- a/dotnet/src/webdriver/Logs.cs +++ b/dotnet/src/webdriver/Logs.cs @@ -50,7 +50,7 @@ public ReadOnlyCollection AvailableLogTypes List availableLogTypes = new List(); 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) @@ -86,7 +86,7 @@ public ReadOnlyCollection GetLog(string logKind) Dictionary parameters = new Dictionary(); 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) { diff --git a/dotnet/src/webdriver/Navigator.cs b/dotnet/src/webdriver/Navigator.cs index db2fe54d6804c..e17f4e3b210c9 100644 --- a/dotnet/src/webdriver/Navigator.cs +++ b/dotnet/src/webdriver/Navigator.cs @@ -57,7 +57,7 @@ public void Back() /// A task object representing the asynchronous operation. public async Task BackAsync() { - await this.driver.InternalExecuteAsync(DriverCommand.GoBack, null).ConfigureAwait(false); + await this.driver.ExecuteAsync(DriverCommand.GoBack, null).ConfigureAwait(false); } /// @@ -77,7 +77,7 @@ public void Forward() /// A task object representing the asynchronous operation. public async Task ForwardAsync() { - await this.driver.InternalExecuteAsync(DriverCommand.GoForward, null).ConfigureAwait(false); + await this.driver.ExecuteAsync(DriverCommand.GoForward, null).ConfigureAwait(false); } /// @@ -110,7 +110,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); } /// @@ -160,7 +160,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); } } } diff --git a/dotnet/src/webdriver/ShadowRoot.cs b/dotnet/src/webdriver/ShadowRoot.cs index 6c0b2513bfac0..8e2e3ea90dc93 100644 --- a/dotnet/src/webdriver/ShadowRoot.cs +++ b/dotnet/src/webdriver/ShadowRoot.cs @@ -96,7 +96,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)!; } @@ -120,7 +120,7 @@ public ReadOnlyCollection 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); } diff --git a/dotnet/src/webdriver/TargetLocator.cs b/dotnet/src/webdriver/TargetLocator.cs index 6cd8a78c09311..d5e779def4f8c 100644 --- a/dotnet/src/webdriver/TargetLocator.cs +++ b/dotnet/src/webdriver/TargetLocator.cs @@ -51,7 +51,7 @@ public IWebDriver Frame(int frameIndex) { Dictionary parameters = new Dictionary(); parameters.Add("id", frameIndex); - this.driver.InternalExecute(DriverCommand.SwitchToFrame, parameters); + this.driver.Execute(DriverCommand.SwitchToFrame, parameters); return this.driver; } @@ -114,7 +114,7 @@ public IWebDriver Frame(IWebElement frameElement) Dictionary parameters = new Dictionary(); parameters.Add("id", elementDictionary); - this.driver.InternalExecute(DriverCommand.SwitchToFrame, parameters); + this.driver.Execute(DriverCommand.SwitchToFrame, parameters); return this.driver; } @@ -125,7 +125,7 @@ public IWebDriver Frame(IWebElement frameElement) public IWebDriver ParentFrame() { Dictionary parameters = new Dictionary(); - this.driver.InternalExecute(DriverCommand.SwitchToParentFrame, parameters); + this.driver.Execute(DriverCommand.SwitchToParentFrame, parameters); return this.driver; } @@ -146,7 +146,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) @@ -193,7 +193,7 @@ public IWebDriver NewWindow(WindowType typeHint) Dictionary parameters = new Dictionary(); parameters.Add("type", typeHint.ToString().ToLowerInvariant()); - Response response = this.driver.InternalExecute(DriverCommand.NewWindow, parameters); + Response response = this.driver.Execute(DriverCommand.NewWindow, parameters); Dictionary result = (Dictionary)response.Value!; string newWindowHandle = result["handle"].ToString()!; @@ -210,7 +210,7 @@ public IWebDriver DefaultContent() { Dictionary parameters = new Dictionary(); parameters.Add("id", null); - this.driver.InternalExecute(DriverCommand.SwitchToFrame, parameters); + this.driver.Execute(DriverCommand.SwitchToFrame, parameters); return this.driver; } @@ -220,7 +220,7 @@ public IWebDriver DefaultContent() /// Element that is active public IWebElement ActiveElement() { - Response response = this.driver.InternalExecute(DriverCommand.GetActiveElement, null); + Response response = this.driver.Execute(DriverCommand.GetActiveElement, null); return this.driver.GetElementFromResponse(response)!; } @@ -232,7 +232,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); } } diff --git a/dotnet/src/webdriver/Timeouts.cs b/dotnet/src/webdriver/Timeouts.cs index 49ee52f8b8935..6f267709d3831 100644 --- a/dotnet/src/webdriver/Timeouts.cs +++ b/dotnet/src/webdriver/Timeouts.cs @@ -109,7 +109,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 responseValue = (Dictionary)commandResponse.Value!; if (!responseValue.TryGetValue(timeoutType, out object? timeout)) @@ -142,7 +142,7 @@ private void ExecuteSetTimeout(string timeoutType, TimeSpan timeToWait) Dictionary parameters = new Dictionary(); parameters.Add(timeoutType, Convert.ToInt64(milliseconds)); - this.driver.InternalExecute(DriverCommand.SetTimeouts, parameters); + this.driver.Execute(DriverCommand.SetTimeouts, parameters); } } } diff --git a/dotnet/src/webdriver/WebDriver.cs b/dotnet/src/webdriver/WebDriver.cs index c9bfdd4c93f04..4008ec1e15b66 100644 --- a/dotnet/src/webdriver/WebDriver.cs +++ b/dotnet/src/webdriver/WebDriver.cs @@ -551,38 +551,6 @@ internal ReadOnlyCollection GetElementsFromResponse(Response respon return toReturn.AsReadOnly(); } - /// - /// Executes commands with the driver - /// - /// Command that needs executing - /// Parameters needed for the command - /// WebDriver Response - /// If is . - internal Response InternalExecute(string driverCommandToExecute, Dictionary? parameters) - { - return Task.Run(() => this.InternalExecuteAsync(driverCommandToExecute, parameters)).GetAwaiter().GetResult(); - } - - /// - /// Executes commands with the driver asynchronously - /// - /// Command that needs executing - /// Parameters needed for the command - /// A task object representing the asynchronous operation - /// If is . - internal Task InternalExecuteAsync(string driverCommandToExecute, Dictionary? parameters) - { - return this.ExecuteAsync(driverCommandToExecute, parameters); - } - /// /// Executes a command with this driver. /// @@ -590,7 +558,7 @@ internal Task InternalExecuteAsync(string driverCommandToExecute, Dict /// A containing the names and values of the parameters of the command. /// A containing information about the success or failure of the command and any data returned by the command. /// If is . - protected virtual Response Execute(string driverCommandToExecute, DictionaryA containing the names and values of the parameters of the command. /// A containing information about the success or failure of the command and any data returned by the command. /// If is . - protected virtual async Task ExecuteAsync(string driverCommandToExecute, Dictionary ExecuteAsync(string driverCommandToExecute, Dictionary? parameters) { - return this.driver.InternalExecute(commandToExecute, parameters); + return this.driver.Execute(commandToExecute, parameters); } private static string GetAtom(string atomResourceName) diff --git a/dotnet/src/webdriver/Window.cs b/dotnet/src/webdriver/Window.cs index 0fe590950b393..8534e506d1e9a 100644 --- a/dotnet/src/webdriver/Window.cs +++ b/dotnet/src/webdriver/Window.cs @@ -48,7 +48,7 @@ public Point Position { get { - Response commandResponse = this.driver.InternalExecute(DriverCommand.GetWindowRect, null); + Response commandResponse = this.driver.Execute(DriverCommand.GetWindowRect, null); Dictionary rawPosition = (Dictionary)commandResponse.Value!; int x = Convert.ToInt32(rawPosition["x"], CultureInfo.InvariantCulture); @@ -62,7 +62,7 @@ public Point Position Dictionary parameters = new Dictionary(); parameters.Add("x", value.X); parameters.Add("y", value.Y); - this.driver.InternalExecute(DriverCommand.SetWindowRect, parameters); + this.driver.Execute(DriverCommand.SetWindowRect, parameters); } } @@ -74,7 +74,7 @@ public Size Size { get { - Response commandResponse = this.driver.InternalExecute(DriverCommand.GetWindowRect, null); + Response commandResponse = this.driver.Execute(DriverCommand.GetWindowRect, null); Dictionary rawPosition = (Dictionary)commandResponse.Value!; int height = Convert.ToInt32(rawPosition["height"], CultureInfo.InvariantCulture); @@ -88,7 +88,7 @@ public Size Size Dictionary parameters = new Dictionary(); parameters.Add("width", value.Width); parameters.Add("height", value.Height); - this.driver.InternalExecute(DriverCommand.SetWindowRect, parameters); + this.driver.Execute(DriverCommand.SetWindowRect, parameters); } } @@ -97,7 +97,7 @@ public Size Size /// public void Maximize() { - this.driver.InternalExecute(DriverCommand.MaximizeWindow, null); + this.driver.Execute(DriverCommand.MaximizeWindow, null); } /// @@ -105,7 +105,7 @@ public void Maximize() /// public void Minimize() { - this.driver.InternalExecute(DriverCommand.MinimizeWindow, null); + this.driver.Execute(DriverCommand.MinimizeWindow, null); } /// @@ -113,7 +113,7 @@ public void Minimize() /// public void FullScreen() { - this.driver.InternalExecute(DriverCommand.FullScreenWindow, null); + this.driver.Execute(DriverCommand.FullScreenWindow, null); } } }