@@ -59,6 +59,46 @@ public async Task AccessCSharpInstanceMembersFromJavaScript()
59
59
Assert . AreEqual ( "Foobar is 20 years old" , str . AsString ( ) ) ;
60
60
}
61
61
62
+ [ Test ]
63
+ public async Task RunScriptSnippetDirectlyGetStringContent ( )
64
+ {
65
+ var html = "<!doctype html><span id=test>Test</span>" ;
66
+ var config = Configuration . Default . WithJavaScript ( ) ;
67
+ var document = await BrowsingContext . New ( config ) . OpenAsync ( m => m . Content ( html ) ) ;
68
+ var result = document . ExecuteScript ( "document.querySelector('#test').innerHTML" ) ;
69
+ Assert . AreEqual ( "Test" , result ) ;
70
+ }
71
+
72
+ [ Test ]
73
+ public async Task RunScriptSnippetDirectlyGetComplexObjectFromProperty ( )
74
+ {
75
+ var html = "<!doctype html><span id=test>Test</span>" ;
76
+ var config = Configuration . Default . WithJavaScript ( ) ;
77
+ var document = await BrowsingContext . New ( config ) . OpenAsync ( m => m . Content ( html ) ) ;
78
+ var result = document . ExecuteScript ( "document.defaultView" ) ;
79
+ Assert . AreEqual ( document . DefaultView , result ) ;
80
+ }
81
+
82
+ [ Test ]
83
+ public async Task RunScriptSnippetDirectlyGetComplexObjectFromQuerySelector ( )
84
+ {
85
+ var html = "<!doctype html><span id=test>Test</span>" ;
86
+ var config = Configuration . Default . WithJavaScript ( ) ;
87
+ var document = await BrowsingContext . New ( config ) . OpenAsync ( m => m . Content ( html ) ) ;
88
+ var result = document . ExecuteScript ( "document.querySelector('#test')" ) ;
89
+ Assert . AreEqual ( document . QuerySelector ( "#test" ) , result ) ;
90
+ }
91
+
92
+ [ Test ]
93
+ public async Task RunScriptSnippetDirectlyGetSimpleValueFromCalculation ( )
94
+ {
95
+ var html = "<!doctype html><span id=test>Test</span>" ;
96
+ var config = Configuration . Default . WithJavaScript ( ) ;
97
+ var document = await BrowsingContext . New ( config ) . OpenAsync ( m => m . Content ( html ) ) ;
98
+ var result = document . ExecuteScript ( "1 + 2 * 3 - 4" ) ;
99
+ Assert . AreEqual ( 3.0 , result ) ;
100
+ }
101
+
62
102
class Person
63
103
{
64
104
public String Name
0 commit comments