Skip to content

Commit 696832f

Browse files
committed
Handle nullability of GetCssValue
1 parent 2ea99a3 commit 696832f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

dotnet/src/webdriver/WebElement.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,6 @@ public virtual ISearchContext GetShadowRoot()
528528
return shadowRoot;
529529
}
530530

531-
#nullable restore
532-
533531
/// <summary>
534532
/// Gets the value of a CSS property of this element.
535533
/// </summary>
@@ -549,10 +547,13 @@ public virtual string GetCssValue(string propertyName)
549547

550548
Response commandResponse = this.Execute(DriverCommand.GetElementValueOfCssProperty, parameters);
551549

552-
return commandResponse.Value.ToString();
553-
}
550+
if (commandResponse.Value is null)
551+
{
552+
throw new WebDriverException("GetElementValueOfCssProperty command returned a successful result, but contained no data");
553+
}
554554

555-
#nullable enable
555+
return commandResponse.Value.ToString()!;
556+
}
556557

557558
/// <summary>
558559
/// Gets a <see cref="Screenshot"/> object representing the image of this element on the screen.

0 commit comments

Comments
 (0)