@@ -40,6 +40,69 @@ func mapBrowserToGoja(vu k6modules.VU) *goja.Object {
40
40
return obj
41
41
}
42
42
43
+ // mapElementHandle to the JS module.
44
+ func mapElementHandle (rt * goja.Runtime , eh api.ElementHandle ) mapping {
45
+ maps := mapping {
46
+ "asElement" : func () * goja.Object {
47
+ m := mapElementHandle (rt , eh .AsElement ())
48
+ return rt .ToValue (m ).ToObject (rt )
49
+ },
50
+ "dispose" : eh .Dispose ,
51
+ "evaluate" : eh .Evaluate ,
52
+ "evaluateHandle" : eh .EvaluateHandle ,
53
+ "getProperties" : eh .GetProperties ,
54
+ "getProperty" : eh .GetProperty ,
55
+ "jSONValue" : eh .JSONValue ,
56
+ "objectID" : eh .ObjectID ,
57
+ "boundingBox" : eh .BoundingBox ,
58
+ "check" : eh .Check ,
59
+ "click" : eh .Click ,
60
+ "contentFrame" : func () * goja.Object {
61
+ f := eh .ContentFrame ()
62
+ mf := mapFrame (rt , f )
63
+ return rt .ToValue (mf ).ToObject (rt )
64
+ },
65
+ "dblclick" : eh .Dblclick ,
66
+ "dispatchEvent" : eh .DispatchEvent ,
67
+ "fill" : eh .Fill ,
68
+ "focus" : eh .Focus ,
69
+ "getAttribute" : eh .GetAttribute ,
70
+ "hover" : eh .Hover ,
71
+ "innerHTML" : eh .InnerHTML ,
72
+ "innerText" : eh .InnerText ,
73
+ "inputValue" : eh .InputValue ,
74
+ "isChecked" : eh .IsChecked ,
75
+ "isDisabled" : eh .IsDisabled ,
76
+ "isEditable" : eh .IsEditable ,
77
+ "isEnabled" : eh .IsEnabled ,
78
+ "isHidden" : eh .IsHidden ,
79
+ "isVisible" : eh .IsVisible ,
80
+ "ownerFrame" : func () * goja.Object {
81
+ f := eh .OwnerFrame ()
82
+ mf := mapFrame (rt , f )
83
+ return rt .ToValue (mf ).ToObject (rt )
84
+ },
85
+ "press" : eh .Press ,
86
+ "screenshot" : eh .Screenshot ,
87
+ "scrollIntoViewIfNeeded" : eh .ScrollIntoViewIfNeeded ,
88
+ "selectOption" : eh .SelectOption ,
89
+ "selectText" : eh .SelectText ,
90
+ "setInputFiles" : eh .SetInputFiles ,
91
+ "tap" : eh .Tap ,
92
+ "textContent" : eh .TextContent ,
93
+ "type" : eh .Type ,
94
+ "uncheck" : eh .Uncheck ,
95
+ "waitForElementState" : eh .WaitForElementState ,
96
+ "waitForSelector" : func (selector string , opts goja.Value ) * goja.Object {
97
+ eh := eh .WaitForSelector (selector , opts )
98
+ ehm := mapElementHandle (rt , eh )
99
+ return rt .ToValue (ehm ).ToObject (rt )
100
+ },
101
+ }
102
+
103
+ return maps
104
+ }
105
+
43
106
// mapFrame to the JS module.
44
107
//
45
108
//nolint:funlen
@@ -66,24 +129,27 @@ func mapFrame(rt *goja.Runtime, f api.Frame) mapping {
66
129
"evaluateHandle" : f .EvaluateHandle ,
67
130
"fill" : f .Fill ,
68
131
"focus" : f .Focus ,
69
- "frameElement" : f .FrameElement ,
70
- "getAttribute" : f .GetAttribute ,
71
- "goto" : f .Goto ,
72
- "hover" : f .Hover ,
73
- "innerHTML" : f .InnerHTML ,
74
- "innerText" : f .InnerText ,
75
- "inputValue" : f .InputValue ,
76
- "isChecked" : f .IsChecked ,
77
- "isDetached" : f .IsDetached ,
78
- "isDisabled" : f .IsDisabled ,
79
- "isEditable" : f .IsEditable ,
80
- "isEnabled" : f .IsEnabled ,
81
- "isHidden" : f .IsHidden ,
82
- "isVisible" : f .IsVisible ,
83
- "iD" : f .ID ,
84
- "loaderID" : f .LoaderID ,
85
- "locator" : f .Locator ,
86
- "name" : f .Name ,
132
+ "frameElement" : func () * goja.Object {
133
+ eh := mapElementHandle (rt , f .FrameElement ())
134
+ return rt .ToValue (eh ).ToObject (rt )
135
+ },
136
+ "getAttribute" : f .GetAttribute ,
137
+ "goto" : f .Goto ,
138
+ "hover" : f .Hover ,
139
+ "innerHTML" : f .InnerHTML ,
140
+ "innerText" : f .InnerText ,
141
+ "inputValue" : f .InputValue ,
142
+ "isChecked" : f .IsChecked ,
143
+ "isDetached" : f .IsDetached ,
144
+ "isDisabled" : f .IsDisabled ,
145
+ "isEditable" : f .IsEditable ,
146
+ "isEnabled" : f .IsEnabled ,
147
+ "isHidden" : f .IsHidden ,
148
+ "isVisible" : f .IsVisible ,
149
+ "iD" : f .ID ,
150
+ "loaderID" : f .LoaderID ,
151
+ "locator" : f .Locator ,
152
+ "name" : f .Name ,
87
153
"page" : func () * goja.Object {
88
154
mp := mapPage (rt , f .Page ())
89
155
return rt .ToValue (mp ).ToObject (rt )
@@ -105,8 +171,12 @@ func mapFrame(rt *goja.Runtime, f api.Frame) mapping {
105
171
"waitForFunction" : f .WaitForFunction ,
106
172
"waitForLoadState" : f .WaitForLoadState ,
107
173
"waitForNavigation" : f .WaitForNavigation ,
108
- "waitForSelector" : f .WaitForSelector ,
109
- "waitForTimeout" : f .WaitForTimeout ,
174
+ "waitForSelector" : func (selector string , opts goja.Value ) * goja.Object {
175
+ eh := f .WaitForSelector (selector , opts )
176
+ ehm := mapElementHandle (rt , eh )
177
+ return rt .ToValue (ehm ).ToObject (rt )
178
+ },
179
+ "waitForTimeout" : f .WaitForTimeout ,
110
180
}
111
181
112
182
return maps
0 commit comments