Skip to content

Commit 44b7ba4

Browse files
elgatovelgato
and
elgato
authored
Cache IWebElement before checking TagName is correct (#8904)
When creating a SelectElement we must first check the WrappedElement tag is select and throw a UnexpectedTagNameException otherwise. Previously the WrappedElement was not cached so WebDriver API could be called up to three times: first to check the tag is not null, second to check it's value is select (ignoring case) and a third time as a parameter of UnexpectedTagNameException if any of the previous conditions failed. Fixes #8899 Co-authored-by: elgato <[email protected]>
1 parent 3dbf71d commit 44b7ba4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

dotnet/src/support/UI/SelectElement.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ public SelectElement(IWebElement element)
4444
throw new ArgumentNullException("element", "element cannot be null");
4545
}
4646

47-
if (string.IsNullOrEmpty(element.TagName) || string.Compare(element.TagName, "select", StringComparison.OrdinalIgnoreCase) != 0)
47+
string tagName = element.TagName;
48+
49+
if (string.IsNullOrEmpty(tagName) || string.Compare(tagName, "select", StringComparison.OrdinalIgnoreCase) != 0)
4850
{
49-
throw new UnexpectedTagNameException("select", element.TagName);
51+
throw new UnexpectedTagNameException("select", tagName);
5052
}
5153

5254
this.element = element;

0 commit comments

Comments
 (0)