@@ -79,10 +79,7 @@ public virtual string TagName
7979
8080 Response commandResponse = this . Execute ( DriverCommand . GetElementTagName , parameters ) ;
8181
82- if ( commandResponse . Value is null )
83- {
84- throw new WebDriverException ( "GetElementTagName command returned a successful result, but contained no data" ) ;
85- }
82+ commandResponse . EnsureValueIsNotNull ( ) ;
8683 return commandResponse . Value . ToString ( ) ! ;
8784 }
8885 }
@@ -101,11 +98,7 @@ public virtual string Text
10198
10299 Response commandResponse = this . Execute ( DriverCommand . GetElementText , parameters ) ;
103100
104- if ( commandResponse . Value is null )
105- {
106- throw new WebDriverException ( "GetElementText command returned a successful result, but contained no data" ) ;
107- }
108-
101+ commandResponse . EnsureValueIsNotNull ( ) ;
109102 return commandResponse . Value . ToString ( ) ! ;
110103 }
111104 }
@@ -248,11 +241,7 @@ public virtual string ComputedAccessibleLabel
248241
249242 Response commandResponse = this . Execute ( DriverCommand . GetComputedAccessibleLabel , parameters ) ;
250243
251- if ( commandResponse . Value is null )
252- {
253- throw new WebDriverException ( "GetComputedAccessibleLabel command returned a successful result, but contained no data" ) ;
254- }
255-
244+ commandResponse . EnsureValueIsNotNull ( ) ;
256245 return commandResponse . Value . ToString ( ) ! ;
257246 }
258247 }
@@ -559,11 +548,7 @@ public virtual string GetCssValue(string propertyName)
559548
560549 Response commandResponse = this . Execute ( DriverCommand . GetElementValueOfCssProperty , parameters ) ;
561550
562- if ( commandResponse . Value is null )
563- {
564- throw new WebDriverException ( "GetElementValueOfCssProperty command returned a successful result, but contained no data" ) ;
565- }
566-
551+ commandResponse . EnsureValueIsNotNull ( ) ;
567552 return commandResponse . Value . ToString ( ) ! ;
568553 }
569554
@@ -578,7 +563,9 @@ public virtual Screenshot GetScreenshot()
578563
579564 // Get the screenshot as base64.
580565 Response screenshotResponse = this . Execute ( DriverCommand . ElementScreenshot , parameters ) ;
581- string base64 = screenshotResponse . Value ? . ToString ( ) ?? throw new WebDriverException ( "ElementScreenshot command returned successfully, but with no response" ) ;
566+
567+ screenshotResponse . EnsureValueIsNotNull ( ) ;
568+ string base64 = screenshotResponse . Value . ToString ( ) ! ;
582569
583570 // ... and convert it.
584571 return new Screenshot ( base64 ) ;
@@ -747,8 +734,6 @@ private static string GetAtom(string atomResourceName)
747734 return wrappedAtom ;
748735 }
749736
750- #nullable restore
751-
752737 private string UploadFile ( string localFile )
753738 {
754739 string base64zip ;
@@ -767,7 +752,9 @@ private string UploadFile(string localFile)
767752 Dictionary < string , object > parameters = new Dictionary < string , object > ( ) ;
768753 parameters . Add ( "file" , base64zip ) ;
769754 Response response = this . Execute ( DriverCommand . UploadFile , parameters ) ;
770- return response . Value . ToString ( ) ;
755+
756+ response . EnsureValueIsNotNull ( ) ;
757+ return response . Value . ToString ( ) ! ;
771758 }
772759 catch ( IOException e )
773760 {
0 commit comments