diff --git a/dotnet/src/support/Extensions/WebDriverExtensions.cs b/dotnet/src/support/Extensions/WebDriverExtensions.cs index 209a08f433756..9b0274b6afded 100644 --- a/dotnet/src/support/Extensions/WebDriverExtensions.cs +++ b/dotnet/src/support/Extensions/WebDriverExtensions.cs @@ -115,7 +115,7 @@ public static void ExecuteJavaScript(this IWebDriver driver, string script, para } } - private static object ExecuteJavaScriptInternal(IWebDriver driver, string script, object?[] args) + private static object? ExecuteJavaScriptInternal(IWebDriver driver, string script, object?[] args) { IJavaScriptExecutor? executor = GetDriverAs(driver) ?? throw new WebDriverException("Driver does not implement IJavaScriptExecutor"); diff --git a/dotnet/src/support/UI/SelectElement.cs b/dotnet/src/support/UI/SelectElement.cs index 3eec3812560a0..070554d54192c 100644 --- a/dotnet/src/support/UI/SelectElement.cs +++ b/dotnet/src/support/UI/SelectElement.cs @@ -53,7 +53,7 @@ public SelectElement(IWebElement element) this.WrappedElement = element; // let check if it's a multiple - string attribute = element.GetAttribute("multiple"); + string? attribute = element.GetAttribute("multiple"); this.IsMultiple = attribute != null && !attribute.Equals("false", StringComparison.OrdinalIgnoreCase); } diff --git a/dotnet/src/webdriver/RelativeBy.cs b/dotnet/src/webdriver/RelativeBy.cs index 553ae402a780b..57d9b7a3f844c 100644 --- a/dotnet/src/webdriver/RelativeBy.cs +++ b/dotnet/src/webdriver/RelativeBy.cs @@ -29,16 +29,13 @@ namespace OpenQA.Selenium /// /// Provides a mechanism for finding elements spatially relative to other elements. /// - public class RelativeBy : By + public sealed class RelativeBy : By { private readonly string wrappedAtom; private readonly object root; private readonly List filters = new List(); - /// - /// Prevents a default instance of the class. - /// - protected RelativeBy() : base() + private static string GetWrappedAtom() { string atom; using (Stream atomStream = ResourceUtilities.GetResourceStream("find-elements.js", "find-elements.js")) @@ -49,13 +46,13 @@ protected RelativeBy() : base() } } - wrappedAtom = string.Format(CultureInfo.InvariantCulture, "/* findElements */return ({0}).apply(null, arguments);", atom); + return string.Format(CultureInfo.InvariantCulture, "/* findElements */return ({0}).apply(null, arguments);", atom); } - private RelativeBy(object root, List? filters = null) : this() + private RelativeBy(object root, List? filters = null) { + this.wrappedAtom = GetWrappedAtom(); this.root = GetSerializableRoot(root); - if (filters != null) { this.filters.AddRange(filters); @@ -73,7 +70,6 @@ public static RelativeBy WithLocator(By by) return new RelativeBy(by); } - /// /// Finds the first element matching the criteria. ///