From 736154ee7b67cb36cf988a72d84f34e9a97d1403 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Mon, 23 Dec 2024 14:26:44 -0500 Subject: [PATCH 01/11] [dotnet] Remove out-of-spec `UnhandledError` error status --- .../webdriver/Remote/HttpCommandExecutor.cs | 2 +- dotnet/src/webdriver/UnknownErrorException.cs | 51 +++++++++++++++++++ .../UnsupportedOperationException.cs | 50 ++++++++++++++++++ dotnet/src/webdriver/WebDriver.cs | 11 ++-- dotnet/src/webdriver/WebDriverError.cs | 4 +- dotnet/src/webdriver/WebDriverResult.cs | 9 +++- 6 files changed, 118 insertions(+), 9 deletions(-) create mode 100644 dotnet/src/webdriver/UnknownErrorException.cs create mode 100644 dotnet/src/webdriver/UnsupportedOperationException.cs diff --git a/dotnet/src/webdriver/Remote/HttpCommandExecutor.cs b/dotnet/src/webdriver/Remote/HttpCommandExecutor.cs index a5d60f67e49ff..0686239405e38 100644 --- a/dotnet/src/webdriver/Remote/HttpCommandExecutor.cs +++ b/dotnet/src/webdriver/Remote/HttpCommandExecutor.cs @@ -326,7 +326,7 @@ private Response CreateResponse(HttpResponseInfo responseInfo) } else { - response.Status = WebDriverResult.UnhandledError; + response.Status = WebDriverResult.UnknownError; response.Value = body; } } diff --git a/dotnet/src/webdriver/UnknownErrorException.cs b/dotnet/src/webdriver/UnknownErrorException.cs new file mode 100644 index 0000000000000..466bc19d9c479 --- /dev/null +++ b/dotnet/src/webdriver/UnknownErrorException.cs @@ -0,0 +1,51 @@ +// +// Licensed to the Software Freedom Conservancy (SFC) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The SFC licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +using System; + +#nullable enable + +namespace OpenQA.Selenium +{ + /// + /// An unknown error occurred in the remote end while processing the command. + /// + [Serializable] + public class UnknownErrorException : WebDriverException + { + /// + /// Initializes a new instance of the class with the specified message. + /// + /// The message of the exception. + public UnknownErrorException(string? message) + : base(message) + { + } + + /// + /// Initializes a new instance of the class with the specified message and inner exception. + /// + /// The message of the exception. + /// The inner exception for this exception. + public UnknownErrorException(string? message, Exception? innerException) + : base(message, innerException) + { + } + } +} diff --git a/dotnet/src/webdriver/UnsupportedOperationException.cs b/dotnet/src/webdriver/UnsupportedOperationException.cs new file mode 100644 index 0000000000000..a8d104400d6b3 --- /dev/null +++ b/dotnet/src/webdriver/UnsupportedOperationException.cs @@ -0,0 +1,50 @@ +// +// Licensed to the Software Freedom Conservancy (SFC) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The SFC licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +using System; + +#nullable enable + +namespace OpenQA.Selenium +{ + /// + /// Indicates that a command that should have executed properly cannot be supported for some reason. + /// + public class UnsupportedOperationException : WebDriverException + { + /// + /// Initializes a new instance of the class with the specified message. + /// + /// The message of the exception. + public UnsupportedOperationException(string? message) + : base(message) + { + } + + /// + /// Initializes a new instance of the class with the specified message and inner exception. + /// + /// The message of the exception. + /// The inner exception for this exception. + public UnsupportedOperationException(string? message, Exception? innerException) + : base(message, innerException) + { + } + } +} diff --git a/dotnet/src/webdriver/WebDriver.cs b/dotnet/src/webdriver/WebDriver.cs index 672aa83b5b6e6..92a6c2619223d 100644 --- a/dotnet/src/webdriver/WebDriver.cs +++ b/dotnet/src/webdriver/WebDriver.cs @@ -622,7 +622,7 @@ protected virtual async Task ExecuteAsync(string driverCommandToExecut { commandResponse = new Response { - Status = WebDriverResult.UnhandledError, + Status = WebDriverResult.UnknownError, Value = e }; } @@ -782,9 +782,6 @@ private static void UnpackAndThrowOnError(Response errorResponse, string command case WebDriverResult.ElementNotSelectable: throw new InvalidElementStateException(errorMessage); - case WebDriverResult.UnhandledError: - throw new WebDriverException(errorMessage); - case WebDriverResult.NoSuchDocument: throw new NoSuchElementException(errorMessage); @@ -854,6 +851,12 @@ private static void UnpackAndThrowOnError(Response errorResponse, string command case WebDriverResult.InsecureCertificate: throw new InsecureCertificateException(errorMessage); + case WebDriverResult.UnknownError: + throw new UnknownErrorException(errorMessage); + + case WebDriverResult.UnsupportedOperation: + throw new UnsupportedOperationException(errorMessage); + default: throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "{0} ({1})", errorMessage, errorResponse.Status)); } diff --git a/dotnet/src/webdriver/WebDriverError.cs b/dotnet/src/webdriver/WebDriverError.cs index e87f8aeae5253..8cf7c6b42d710 100644 --- a/dotnet/src/webdriver/WebDriverError.cs +++ b/dotnet/src/webdriver/WebDriverError.cs @@ -223,9 +223,9 @@ static WebDriverError() resultMap[UnableToCaptureScreen] = WebDriverResult.UnableToCaptureScreen; resultMap[UnexpectedAlertOpen] = WebDriverResult.UnexpectedAlertOpen; resultMap[UnknownCommand] = WebDriverResult.UnknownCommand; - resultMap[UnknownError] = WebDriverResult.UnhandledError; + resultMap[UnknownError] = WebDriverResult.UnknownError; resultMap[UnknownMethod] = WebDriverResult.UnknownCommand; - resultMap[UnsupportedOperation] = WebDriverResult.UnhandledError; + resultMap[UnsupportedOperation] = WebDriverResult.UnsupportedOperation; } /// diff --git a/dotnet/src/webdriver/WebDriverResult.cs b/dotnet/src/webdriver/WebDriverResult.cs index 962c21d4bac76..8e197c5443f5c 100644 --- a/dotnet/src/webdriver/WebDriverResult.cs +++ b/dotnet/src/webdriver/WebDriverResult.cs @@ -90,9 +90,9 @@ public enum WebDriverResult InvalidElementState = 12, /// - /// An unhandled error occurred. + /// An unknown error occurred in the remote end while processing the command. /// - UnhandledError = 13, + UnknownError = 13, /// /// An error occurred, but it was expected. @@ -233,5 +233,10 @@ public enum WebDriverResult /// The referenced shadow root is no longer attached to the DOM. /// DetachedShadowRoot = 66, + + /// + /// Indicates that a command that should have executed properly cannot be supported for some reason. + /// + UnsupportedOperation = 67, } } From 46eea5532c3b58561599152d15da053607490224 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Thu, 26 Dec 2024 00:14:02 -0500 Subject: [PATCH 02/11] Align webdriver errors with spec, mitigate breaking change --- .../src/webdriver/UnknownMethodException.cs | 49 +++++++++++++ dotnet/src/webdriver/WebDriver.cs | 3 + dotnet/src/webdriver/WebDriverError.cs | 68 ++++++++++--------- dotnet/src/webdriver/WebDriverResult.cs | 63 ++++++++++------- 4 files changed, 125 insertions(+), 58 deletions(-) create mode 100644 dotnet/src/webdriver/UnknownMethodException.cs diff --git a/dotnet/src/webdriver/UnknownMethodException.cs b/dotnet/src/webdriver/UnknownMethodException.cs new file mode 100644 index 0000000000000..168fc2dfedbec --- /dev/null +++ b/dotnet/src/webdriver/UnknownMethodException.cs @@ -0,0 +1,49 @@ +// +// Licensed to the Software Freedom Conservancy (SFC) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The SFC licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +// + +using System; + +#nullable enable + +namespace OpenQA.Selenium +{ + /// + /// Exception that is thrown when the requested command matched a known URL but did not match any method for that URL. + /// + [Serializable] + public class UnknownMethodException : WebDriverException + { + /// + /// Initializes a new instance of the class with the specified message. + /// + /// The message of the exception. + public UnknownMethodException(string? message) : base(message) + { + } + + /// + /// Initializes a new instance of the class with the specified message and inner exception. + /// + /// The message of the exception. + /// The inner exception for this exception. + public UnknownMethodException(string? message, Exception? innerException) : base(message, innerException) + { + } + } +} diff --git a/dotnet/src/webdriver/WebDriver.cs b/dotnet/src/webdriver/WebDriver.cs index 92a6c2619223d..57d1a2bab91fc 100644 --- a/dotnet/src/webdriver/WebDriver.cs +++ b/dotnet/src/webdriver/WebDriver.cs @@ -854,6 +854,9 @@ private static void UnpackAndThrowOnError(Response errorResponse, string command case WebDriverResult.UnknownError: throw new UnknownErrorException(errorMessage); + case WebDriverResult.UnknownMethod: + throw new UnknownMethodException(errorMessage); + case WebDriverResult.UnsupportedOperation: throw new UnsupportedOperationException(errorMessage); diff --git a/dotnet/src/webdriver/WebDriverError.cs b/dotnet/src/webdriver/WebDriverError.cs index 8cf7c6b42d710..4318c5cb1361b 100644 --- a/dotnet/src/webdriver/WebDriverError.cs +++ b/dotnet/src/webdriver/WebDriverError.cs @@ -27,32 +27,16 @@ namespace OpenQA.Selenium /// internal static class WebDriverError { - /// - /// Represents the detached shadow root error. - /// - public const string DetachedShadowRoot = "detached shadow root"; - /// /// Represents the element click intercepted error. /// public const string ElementClickIntercepted = "element click intercepted"; - /// - /// Represents the element not selectable error. - /// - public const string ElementNotSelectable = "element not selectable"; - /// /// Represents the element not interactable error. /// public const string ElementNotInteractable = "element not interactable"; - /// - /// Represents the element not visible error. - /// - /// TODO: Remove this string; it is no longer valid in the specification. - public const string ElementNotVisible = "element not visible"; - /// /// Represents the insecure certificate error. /// @@ -68,17 +52,6 @@ internal static class WebDriverError /// public const string InvalidCookieDomain = "invalid cookie domain"; - /// - /// Represents the invalid coordinates error. - /// - public const string InvalidCoordinates = "invalid coordinates"; - - /// - /// Represents the invalid element coordinates error. - /// - /// TODO: Remove this string; it is no longer valid in the specification. - public const string InvalidElementCoordinates = "invalid element coordinates"; - /// /// Represents the invalid element state error. /// @@ -149,6 +122,11 @@ internal static class WebDriverError /// public const string StaleElementReference = "stale element reference"; + /// + /// Represents the detached shadow root error. + /// + public const string DetachedShadowRoot = "detached shadow root"; + /// /// Represents the timeout error. /// @@ -189,21 +167,38 @@ internal static class WebDriverError /// public const string UnsupportedOperation = "unsupported operation"; + /// + /// Represents the element not selectable error. + /// + public const string ElementNotSelectable = "element not selectable"; + + /// + /// Represents the element not visible error. + /// + /// TODO: Remove this string; it is no longer valid in the specification. + public const string ElementNotVisible = "element not visible"; + + /// + /// Represents the invalid coordinates error. + /// + public const string InvalidCoordinates = "invalid coordinates"; + + /// + /// Represents the invalid element coordinates error. + /// + /// TODO: Remove this string; it is no longer valid in the specification. + public const string InvalidElementCoordinates = "invalid element coordinates"; + private static readonly Dictionary resultMap; static WebDriverError() { resultMap = new Dictionary(); - resultMap[DetachedShadowRoot] = WebDriverResult.DetachedShadowRoot; resultMap[ElementClickIntercepted] = WebDriverResult.ElementClickIntercepted; - resultMap[ElementNotSelectable] = WebDriverResult.ElementNotSelectable; - resultMap[ElementNotVisible] = WebDriverResult.ElementNotDisplayed; resultMap[ElementNotInteractable] = WebDriverResult.ElementNotInteractable; resultMap[InsecureCertificate] = WebDriverResult.InsecureCertificate; resultMap[InvalidArgument] = WebDriverResult.InvalidArgument; resultMap[InvalidCookieDomain] = WebDriverResult.InvalidCookieDomain; - resultMap[InvalidCoordinates] = WebDriverResult.InvalidElementCoordinates; - resultMap[InvalidElementCoordinates] = WebDriverResult.InvalidElementCoordinates; resultMap[InvalidElementState] = WebDriverResult.InvalidElementState; resultMap[InvalidSelector] = WebDriverResult.InvalidSelector; resultMap[InvalidSessionId] = WebDriverResult.NoSuchDriver; @@ -218,14 +213,21 @@ static WebDriverError() resultMap[ScriptTimeout] = WebDriverResult.AsyncScriptTimeout; resultMap[SessionNotCreated] = WebDriverResult.SessionNotCreated; resultMap[StaleElementReference] = WebDriverResult.ObsoleteElement; + resultMap[DetachedShadowRoot] = WebDriverResult.DetachedShadowRoot; resultMap[Timeout] = WebDriverResult.Timeout; resultMap[UnableToSetCookie] = WebDriverResult.UnableToSetCookie; resultMap[UnableToCaptureScreen] = WebDriverResult.UnableToCaptureScreen; resultMap[UnexpectedAlertOpen] = WebDriverResult.UnexpectedAlertOpen; resultMap[UnknownCommand] = WebDriverResult.UnknownCommand; resultMap[UnknownError] = WebDriverResult.UnknownError; - resultMap[UnknownMethod] = WebDriverResult.UnknownCommand; + resultMap[UnknownMethod] = WebDriverResult.UnknownMethod; resultMap[UnsupportedOperation] = WebDriverResult.UnsupportedOperation; + + // TODO: Remove these strings; it is no longer valid in the specification. + resultMap[ElementNotSelectable] = WebDriverResult.ElementNotSelectable; + resultMap[ElementNotVisible] = WebDriverResult.ElementNotDisplayed; + resultMap[InvalidCoordinates] = WebDriverResult.InvalidElementCoordinates; + resultMap[InvalidElementCoordinates] = WebDriverResult.InvalidElementCoordinates; } /// diff --git a/dotnet/src/webdriver/WebDriverResult.cs b/dotnet/src/webdriver/WebDriverResult.cs index 8e197c5443f5c..ed94b1a73d5ca 100644 --- a/dotnet/src/webdriver/WebDriverResult.cs +++ b/dotnet/src/webdriver/WebDriverResult.cs @@ -17,6 +17,8 @@ // under the License. // +using System; + namespace OpenQA.Selenium { /// @@ -55,27 +57,27 @@ public enum WebDriverResult NoStringWrapper = 5, /// - /// No driver matching the criteria exists. + /// Occurs if the given session id is not in the list of active sessions, meaning the session either does not exist or that it's not active. /// NoSuchDriver = 6, /// - /// No element matching the criteria exists. + /// An element could not be located on the page using the given search parameters. /// NoSuchElement = 7, /// - /// No frame matching the criteria exists. + /// A command to switch to a frame could not be satisfied because the frame could not be found. /// NoSuchFrame = 8, /// - /// The functionality is not supported. + /// A command could not be executed because the remote end is not aware of it. /// UnknownCommand = 9, /// - /// The specified element is no longer valid. + /// A command failed because the referenced element is no longer attached to the DOM. /// ObsoleteElement = 10, @@ -85,15 +87,21 @@ public enum WebDriverResult ElementNotDisplayed = 11, /// - /// The specified element is not enabled. + /// A command could not be completed because the element is in an invalid state, e.g. attempting to clear an element that isn't both editable and resettable. /// InvalidElementState = 12, /// - /// An unknown error occurred in the remote end while processing the command. + /// An unknown error occurred in the remote end while processing the command. /// UnknownError = 13, + /// + /// An unhandled error occurred. + /// + [Obsolete("This value is no longer set for unknown errors: use UnknownError instead")] + UnhandledError = UnknownError, + /// /// An error occurred, but it was expected. /// @@ -110,7 +118,7 @@ public enum WebDriverResult NoSuchDocument = 16, /// - /// An unexpected JavaScript error occurred. + /// An error occurred while executing JavaScript supplied by the user. /// UnexpectedJavaScriptError = 17, @@ -130,7 +138,7 @@ public enum WebDriverResult NoSuchCollection = 20, /// - /// A timeout occurred. + /// An operation did not complete before its timeout expired. /// Timeout = 21, @@ -140,32 +148,32 @@ public enum WebDriverResult NullPointer = 22, /// - /// No window matching the criteria exists. + /// A command to switch to a window could not be satisfied because the window could not be found. /// NoSuchWindow = 23, /// - /// An illegal attempt was made to set a cookie under a different domain than the current page. + /// An illegal attempt was made to set a cookie under a different domain than the current page.. /// InvalidCookieDomain = 24, /// - /// A request to set a cookie's value could not be satisfied. + /// A command to set a cookie's value could not be satisfied. /// UnableToSetCookie = 25, /// - /// An alert was found open unexpectedly. + /// A modal dialog was open, blocking this operation. /// UnexpectedAlertOpen = 26, /// - /// A request was made to switch to an alert, but no alert is currently open. + /// An attempt was made to operate on a modal dialog when one was not open. /// NoAlertPresent = 27, /// - /// An asynchronous JavaScript execution timed out. + /// A script did not complete before its timeout expired. /// AsyncScriptTimeout = 28, @@ -175,17 +183,17 @@ public enum WebDriverResult InvalidElementCoordinates = 29, /// - /// The selector used (CSS/XPath) was invalid. + /// Argument was an invalid selector. /// InvalidSelector = 32, /// - /// A session was not created by the driver + /// A new session could not be created. /// SessionNotCreated = 33, /// - /// The requested move was outside the active view port + /// The target for mouse interaction is not in the browser's viewport and cannot be brought into that viewport. /// MoveTargetOutOfBounds = 34, @@ -195,32 +203,32 @@ public enum WebDriverResult InvalidXPathSelector = 51, /// - /// An insecure SSl certificate was specified. + /// Navigation caused the user agent to hit a certificate warning, which is usually the result of an expired or invalid TLS certificate. /// InsecureCertificate = 59, /// - /// The element was not interactable + /// A command could not be completed because the element is not pointer- or keyboard interactable. /// ElementNotInteractable = 60, /// - /// An invalid argument was passed to the command. + /// The arguments passed to a command are either invalid or malformed. /// InvalidArgument = 61, /// - /// No cookie was found matching the name requested. + /// No cookie matching the given path name was found amongst the associated cookies of session's current browsing context's active document. /// NoSuchCookie = 62, /// - /// The driver was unable to capture the screen. + /// A screen capture was made impossible. /// UnableToCaptureScreen = 63, /// - /// The click on the element was intercepted by a different element. + /// The Element Click command could not be completed because the element receiving the events is obscuring the element that was requested clicked. /// ElementClickIntercepted = 64, @@ -234,9 +242,14 @@ public enum WebDriverResult /// DetachedShadowRoot = 66, + /// + /// The requested command matched a known URL but did not match any method for that URL. + /// + UnknownMethod = 67, + /// /// Indicates that a command that should have executed properly cannot be supported for some reason. /// - UnsupportedOperation = 67, + UnsupportedOperation = 68, } } From dffd894f0a1b0ce76537ce67b350e149f3b72c92 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Thu, 26 Dec 2024 12:49:29 -0500 Subject: [PATCH 03/11] Obsolete webdriver results that W3C spec no longer returns --- dotnet/src/webdriver/WebDriverError.cs | 2 ++ dotnet/src/webdriver/WebDriverResult.cs | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/dotnet/src/webdriver/WebDriverError.cs b/dotnet/src/webdriver/WebDriverError.cs index 4318c5cb1361b..32453a55ff6b2 100644 --- a/dotnet/src/webdriver/WebDriverError.cs +++ b/dotnet/src/webdriver/WebDriverError.cs @@ -224,10 +224,12 @@ static WebDriverError() resultMap[UnsupportedOperation] = WebDriverResult.UnsupportedOperation; // TODO: Remove these strings; it is no longer valid in the specification. +#pragma warning disable CS0618 // Type or member is obsolete resultMap[ElementNotSelectable] = WebDriverResult.ElementNotSelectable; resultMap[ElementNotVisible] = WebDriverResult.ElementNotDisplayed; resultMap[InvalidCoordinates] = WebDriverResult.InvalidElementCoordinates; resultMap[InvalidElementCoordinates] = WebDriverResult.InvalidElementCoordinates; +#pragma warning restore CS0618 // Type or member is obsolete } /// diff --git a/dotnet/src/webdriver/WebDriverResult.cs b/dotnet/src/webdriver/WebDriverResult.cs index ed94b1a73d5ca..6d966920fc8a1 100644 --- a/dotnet/src/webdriver/WebDriverResult.cs +++ b/dotnet/src/webdriver/WebDriverResult.cs @@ -34,26 +34,31 @@ public enum WebDriverResult /// /// The index specified for the action was out of the acceptable range. /// + [Obsolete("This result is not returned by W3C specifications")] IndexOutOfBounds = 1, /// /// No collection was specified. /// + [Obsolete("This result is not returned by W3C specifications")] NoCollection = 2, /// /// No string was specified. /// + [Obsolete("This result is not returned by W3C specifications")] NoString = 3, /// /// No string length was specified. /// + [Obsolete("This result is not returned by W3C specifications")] NoStringLength = 4, /// /// No string wrapper was specified. /// + [Obsolete("This result is not returned by W3C specifications")] NoStringWrapper = 5, /// @@ -84,6 +89,7 @@ public enum WebDriverResult /// /// The specified element is not displayed. /// + [Obsolete("This result is not returned by W3C specifications")] ElementNotDisplayed = 11, /// @@ -105,11 +111,13 @@ public enum WebDriverResult /// /// An error occurred, but it was expected. /// + [Obsolete("This result is not returned by W3C specifications")] ExpectedError = 14, /// /// The specified element is not selected. /// + [Obsolete("This result is not returned by W3C specifications")] ElementNotSelectable = 15, /// @@ -125,16 +133,19 @@ public enum WebDriverResult /// /// No result is available from the JavaScript execution. /// + [Obsolete("This result is not returned by W3C specifications")] NoScriptResult = 18, /// /// The result from the JavaScript execution is not recognized. /// + [Obsolete("This result is not returned by W3C specifications")] XPathLookupError = 19, /// /// No collection matching the criteria exists. /// + [Obsolete("This result is not returned by W3C specifications")] NoSuchCollection = 20, /// @@ -145,6 +156,7 @@ public enum WebDriverResult /// /// A null pointer was received. /// + [Obsolete("This result is not returned by W3C specifications")] NullPointer = 22, /// @@ -180,6 +192,7 @@ public enum WebDriverResult /// /// The coordinates of the element are invalid. /// + [Obsolete("This result is not returned by W3C specifications")] InvalidElementCoordinates = 29, /// @@ -200,6 +213,7 @@ public enum WebDriverResult /// /// The XPath selector was invalid. /// + [Obsolete("This result is not returned by W3C specifications")] InvalidXPathSelector = 51, /// From 091406783f030f822fe812a2694af9e8229d611a Mon Sep 17 00:00:00 2001 From: Michael Render Date: Thu, 26 Dec 2024 12:52:51 -0500 Subject: [PATCH 04/11] Add obsoletion to `NoSuchDocument` as well --- dotnet/src/webdriver/WebDriverResult.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/dotnet/src/webdriver/WebDriverResult.cs b/dotnet/src/webdriver/WebDriverResult.cs index 6d966920fc8a1..0ade760acf545 100644 --- a/dotnet/src/webdriver/WebDriverResult.cs +++ b/dotnet/src/webdriver/WebDriverResult.cs @@ -123,6 +123,7 @@ public enum WebDriverResult /// /// No document matching the criteria exists. /// + [Obsolete("This result is not returned by W3C specifications")] NoSuchDocument = 16, /// From bd62f6f3757180d6d50b2a5bd0592d3ed8e787c5 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Thu, 26 Dec 2024 13:06:35 -0500 Subject: [PATCH 05/11] remove extra period in XML doc --- dotnet/src/webdriver/WebDriverResult.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet/src/webdriver/WebDriverResult.cs b/dotnet/src/webdriver/WebDriverResult.cs index 0ade760acf545..7dfed27a62198 100644 --- a/dotnet/src/webdriver/WebDriverResult.cs +++ b/dotnet/src/webdriver/WebDriverResult.cs @@ -166,7 +166,7 @@ public enum WebDriverResult NoSuchWindow = 23, /// - /// An illegal attempt was made to set a cookie under a different domain than the current page.. + /// An illegal attempt was made to set a cookie under a different domain than the current page. /// InvalidCookieDomain = 24, From a14ea4b39297c94b71dd29ec1d42e18075399ce2 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Thu, 26 Dec 2024 13:48:08 -0500 Subject: [PATCH 06/11] Update obsoletion message for unused webdriver results --- dotnet/src/webdriver/WebDriverResult.cs | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/dotnet/src/webdriver/WebDriverResult.cs b/dotnet/src/webdriver/WebDriverResult.cs index 7dfed27a62198..875c1103beda2 100644 --- a/dotnet/src/webdriver/WebDriverResult.cs +++ b/dotnet/src/webdriver/WebDriverResult.cs @@ -34,31 +34,31 @@ public enum WebDriverResult /// /// The index specified for the action was out of the acceptable range. /// - [Obsolete("This result is not returned by W3C specifications")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] IndexOutOfBounds = 1, /// /// No collection was specified. /// - [Obsolete("This result is not returned by W3C specifications")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] NoCollection = 2, /// /// No string was specified. /// - [Obsolete("This result is not returned by W3C specifications")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] NoString = 3, /// /// No string length was specified. /// - [Obsolete("This result is not returned by W3C specifications")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] NoStringLength = 4, /// /// No string wrapper was specified. /// - [Obsolete("This result is not returned by W3C specifications")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] NoStringWrapper = 5, /// @@ -89,7 +89,7 @@ public enum WebDriverResult /// /// The specified element is not displayed. /// - [Obsolete("This result is not returned by W3C specifications")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] ElementNotDisplayed = 11, /// @@ -111,19 +111,19 @@ public enum WebDriverResult /// /// An error occurred, but it was expected. /// - [Obsolete("This result is not returned by W3C specifications")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] ExpectedError = 14, /// /// The specified element is not selected. /// - [Obsolete("This result is not returned by W3C specifications")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] ElementNotSelectable = 15, /// /// No document matching the criteria exists. /// - [Obsolete("This result is not returned by W3C specifications")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] NoSuchDocument = 16, /// @@ -134,19 +134,19 @@ public enum WebDriverResult /// /// No result is available from the JavaScript execution. /// - [Obsolete("This result is not returned by W3C specifications")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] NoScriptResult = 18, /// /// The result from the JavaScript execution is not recognized. /// - [Obsolete("This result is not returned by W3C specifications")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] XPathLookupError = 19, /// /// No collection matching the criteria exists. /// - [Obsolete("This result is not returned by W3C specifications")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] NoSuchCollection = 20, /// @@ -157,7 +157,7 @@ public enum WebDriverResult /// /// A null pointer was received. /// - [Obsolete("This result is not returned by W3C specifications")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] NullPointer = 22, /// @@ -193,7 +193,7 @@ public enum WebDriverResult /// /// The coordinates of the element are invalid. /// - [Obsolete("This result is not returned by W3C specifications")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] InvalidElementCoordinates = 29, /// @@ -214,7 +214,7 @@ public enum WebDriverResult /// /// The XPath selector was invalid. /// - [Obsolete("This result is not returned by W3C specifications")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] InvalidXPathSelector = 51, /// From edb9967fc1ab37d69e1958ffaf4b542ca6c164e2 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Thu, 26 Dec 2024 14:41:28 -0500 Subject: [PATCH 07/11] Remove mapping to obsolete webdriver errors, obsolete public-facing messages --- dotnet/src/webdriver/WebDriverError.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/dotnet/src/webdriver/WebDriverError.cs b/dotnet/src/webdriver/WebDriverError.cs index 32453a55ff6b2..875bff1fc59a4 100644 --- a/dotnet/src/webdriver/WebDriverError.cs +++ b/dotnet/src/webdriver/WebDriverError.cs @@ -17,6 +17,7 @@ // under the License. // +using System; using System.Collections.Generic; namespace OpenQA.Selenium @@ -170,23 +171,26 @@ internal static class WebDriverError /// /// Represents the element not selectable error. /// + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] public const string ElementNotSelectable = "element not selectable"; /// /// Represents the element not visible error. /// /// TODO: Remove this string; it is no longer valid in the specification. + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] public const string ElementNotVisible = "element not visible"; /// /// Represents the invalid coordinates error. /// + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] public const string InvalidCoordinates = "invalid coordinates"; /// /// Represents the invalid element coordinates error. /// - /// TODO: Remove this string; it is no longer valid in the specification. + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] public const string InvalidElementCoordinates = "invalid element coordinates"; private static readonly Dictionary resultMap; @@ -222,14 +226,6 @@ static WebDriverError() resultMap[UnknownError] = WebDriverResult.UnknownError; resultMap[UnknownMethod] = WebDriverResult.UnknownMethod; resultMap[UnsupportedOperation] = WebDriverResult.UnsupportedOperation; - - // TODO: Remove these strings; it is no longer valid in the specification. -#pragma warning disable CS0618 // Type or member is obsolete - resultMap[ElementNotSelectable] = WebDriverResult.ElementNotSelectable; - resultMap[ElementNotVisible] = WebDriverResult.ElementNotDisplayed; - resultMap[InvalidCoordinates] = WebDriverResult.InvalidElementCoordinates; - resultMap[InvalidElementCoordinates] = WebDriverResult.InvalidElementCoordinates; -#pragma warning restore CS0618 // Type or member is obsolete } /// From f3c253e61f863661413808d4b2175270c3d3c845 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Thu, 26 Dec 2024 14:42:57 -0500 Subject: [PATCH 08/11] remove TODO --- dotnet/src/webdriver/WebDriverError.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/dotnet/src/webdriver/WebDriverError.cs b/dotnet/src/webdriver/WebDriverError.cs index 875bff1fc59a4..fa83d9817c837 100644 --- a/dotnet/src/webdriver/WebDriverError.cs +++ b/dotnet/src/webdriver/WebDriverError.cs @@ -177,7 +177,6 @@ internal static class WebDriverError /// /// Represents the element not visible error. /// - /// TODO: Remove this string; it is no longer valid in the specification. [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] public const string ElementNotVisible = "element not visible"; From 137eecbf283d14eb4b34cbdb3a6fa6ef2d690323 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Thu, 26 Dec 2024 14:47:23 -0500 Subject: [PATCH 09/11] Remove not-actually-public strings --- dotnet/src/webdriver/WebDriverError.cs | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/dotnet/src/webdriver/WebDriverError.cs b/dotnet/src/webdriver/WebDriverError.cs index fa83d9817c837..5811d924f53cb 100644 --- a/dotnet/src/webdriver/WebDriverError.cs +++ b/dotnet/src/webdriver/WebDriverError.cs @@ -17,7 +17,6 @@ // under the License. // -using System; using System.Collections.Generic; namespace OpenQA.Selenium @@ -168,30 +167,6 @@ internal static class WebDriverError /// public const string UnsupportedOperation = "unsupported operation"; - /// - /// Represents the element not selectable error. - /// - [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] - public const string ElementNotSelectable = "element not selectable"; - - /// - /// Represents the element not visible error. - /// - [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] - public const string ElementNotVisible = "element not visible"; - - /// - /// Represents the invalid coordinates error. - /// - [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] - public const string InvalidCoordinates = "invalid coordinates"; - - /// - /// Represents the invalid element coordinates error. - /// - [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] - public const string InvalidElementCoordinates = "invalid element coordinates"; - private static readonly Dictionary resultMap; static WebDriverError() From 36f4a477cd61b446553cf86290f36c17654e7070 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Thu, 26 Dec 2024 15:13:35 -0500 Subject: [PATCH 10/11] Add removal version to obsoletion messages --- dotnet/src/webdriver/WebDriverResult.cs | 34 ++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/dotnet/src/webdriver/WebDriverResult.cs b/dotnet/src/webdriver/WebDriverResult.cs index 875c1103beda2..7c4b54e84e6bb 100644 --- a/dotnet/src/webdriver/WebDriverResult.cs +++ b/dotnet/src/webdriver/WebDriverResult.cs @@ -34,37 +34,37 @@ public enum WebDriverResult /// /// The index specified for the action was out of the acceptable range. /// - [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")] IndexOutOfBounds = 1, /// /// No collection was specified. /// - [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")] NoCollection = 2, /// /// No string was specified. /// - [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")] NoString = 3, /// /// No string length was specified. /// - [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")] NoStringLength = 4, /// /// No string wrapper was specified. /// - [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")] NoStringWrapper = 5, /// /// Occurs if the given session id is not in the list of active sessions, meaning the session either does not exist or that it's not active. /// - NoSuchDriver = 6, + NoSuchDriver = IndexOutOfBounds, /// /// An element could not be located on the page using the given search parameters. @@ -89,7 +89,7 @@ public enum WebDriverResult /// /// The specified element is not displayed. /// - [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")] ElementNotDisplayed = 11, /// @@ -105,25 +105,25 @@ public enum WebDriverResult /// /// An unhandled error occurred. /// - [Obsolete("This value is no longer set for unknown errors: use UnknownError instead")] + [Obsolete("This value is no longer set for unknown errors: use UnknownError instead. Will be removed in 4.30")] UnhandledError = UnknownError, /// /// An error occurred, but it was expected. /// - [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")] ExpectedError = 14, /// /// The specified element is not selected. /// - [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")] ElementNotSelectable = 15, /// /// No document matching the criteria exists. /// - [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")] NoSuchDocument = 16, /// @@ -134,19 +134,19 @@ public enum WebDriverResult /// /// No result is available from the JavaScript execution. /// - [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")] NoScriptResult = 18, /// /// The result from the JavaScript execution is not recognized. /// - [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")] XPathLookupError = 19, /// /// No collection matching the criteria exists. /// - [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")] NoSuchCollection = 20, /// @@ -157,7 +157,7 @@ public enum WebDriverResult /// /// A null pointer was received. /// - [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")] NullPointer = 22, /// @@ -193,7 +193,7 @@ public enum WebDriverResult /// /// The coordinates of the element are invalid. /// - [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")] InvalidElementCoordinates = 29, /// @@ -214,7 +214,7 @@ public enum WebDriverResult /// /// The XPath selector was invalid. /// - [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors")] + [Obsolete("This error status is no longer returned by the WebDriver Specification https://www.w3.org/TR/webdriver2/#errors. Will be removed in 4.30")] InvalidXPathSelector = 51, /// From 11ceeedeb0bddd5329a56ea9d32542a254c47be2 Mon Sep 17 00:00:00 2001 From: Michael Render Date: Thu, 26 Dec 2024 15:16:41 -0500 Subject: [PATCH 11/11] remove accidental push --- dotnet/src/webdriver/WebDriverResult.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet/src/webdriver/WebDriverResult.cs b/dotnet/src/webdriver/WebDriverResult.cs index 7c4b54e84e6bb..a18dcce7c6a42 100644 --- a/dotnet/src/webdriver/WebDriverResult.cs +++ b/dotnet/src/webdriver/WebDriverResult.cs @@ -64,7 +64,7 @@ public enum WebDriverResult /// /// Occurs if the given session id is not in the list of active sessions, meaning the session either does not exist or that it's not active. /// - NoSuchDriver = IndexOutOfBounds, + NoSuchDriver = 6, /// /// An element could not be located on the page using the given search parameters.