@@ -25,46 +25,32 @@ namespace OpenQA.Selenium.BiDi.Modules.Script;
25
25
26
26
public sealed class ScriptModule ( Broker broker ) : Module ( broker )
27
27
{
28
- public async Task < EvaluateResultSuccess > EvaluateAsync ( string expression , bool awaitPromise , Target target , EvaluateOptions ? options = null )
28
+ public async Task < EvaluateResult > EvaluateAsync ( string expression , bool awaitPromise , Target target , EvaluateOptions ? options = null )
29
29
{
30
30
var @params = new EvaluateCommandParameters ( expression , target , awaitPromise , options ? . ResultOwnership , options ? . SerializationOptions , options ? . UserActivation ) ;
31
31
32
- var result = await Broker . ExecuteCommandAsync < EvaluateCommand , EvaluateResult > ( new EvaluateCommand ( @params ) , options ) . ConfigureAwait ( false ) ;
33
-
34
- if ( result is EvaluateResultException exp )
35
- {
36
- throw new ScriptEvaluateException ( exp ) ;
37
- }
38
-
39
- return ( EvaluateResultSuccess ) result ;
32
+ return await Broker . ExecuteCommandAsync < EvaluateCommand , EvaluateResult > ( new EvaluateCommand ( @params ) , options ) . ConfigureAwait ( false ) ;
40
33
}
41
34
42
35
public async Task < TResult ? > EvaluateAsync < TResult > ( string expression , bool awaitPromise , Target target , EvaluateOptions ? options = null )
43
36
{
44
37
var result = await EvaluateAsync ( expression , awaitPromise , target , options ) . ConfigureAwait ( false ) ;
45
38
46
- return result . Result . ConvertTo < TResult > ( ) ;
39
+ return result . AsSuccessResult ( ) . ConvertTo < TResult > ( ) ;
47
40
}
48
41
49
- public async Task < EvaluateResultSuccess > CallFunctionAsync ( string functionDeclaration , bool awaitPromise , Target target , CallFunctionOptions ? options = null )
42
+ public async Task < EvaluateResult > CallFunctionAsync ( string functionDeclaration , bool awaitPromise , Target target , CallFunctionOptions ? options = null )
50
43
{
51
44
var @params = new CallFunctionCommandParameters ( functionDeclaration , awaitPromise , target , options ? . Arguments , options ? . ResultOwnership , options ? . SerializationOptions , options ? . This , options ? . UserActivation ) ;
52
45
53
- var result = await Broker . ExecuteCommandAsync < CallFunctionCommand , EvaluateResult > ( new CallFunctionCommand ( @params ) , options ) . ConfigureAwait ( false ) ;
54
-
55
- if ( result is EvaluateResultException exp )
56
- {
57
- throw new ScriptEvaluateException ( exp ) ;
58
- }
59
-
60
- return ( EvaluateResultSuccess ) result ;
46
+ return await Broker . ExecuteCommandAsync < CallFunctionCommand , EvaluateResult > ( new CallFunctionCommand ( @params ) , options ) . ConfigureAwait ( false ) ;
61
47
}
62
48
63
49
public async Task < TResult ? > CallFunctionAsync < TResult > ( string functionDeclaration , bool awaitPromise , Target target , CallFunctionOptions ? options = null )
64
50
{
65
51
var result = await CallFunctionAsync ( functionDeclaration , awaitPromise , target , options ) . ConfigureAwait ( false ) ;
66
52
67
- return result . Result . ConvertTo < TResult > ( ) ;
53
+ return result . AsSuccessResult ( ) . ConvertTo < TResult > ( ) ;
68
54
}
69
55
70
56
public async Task < GetRealmsResult > GetRealmsAsync ( GetRealmsOptions ? options = null )
0 commit comments