@@ -236,3 +236,57 @@ Func _WD_WaitElement($sSession, $sStrategy, $sSelector, $iDelay = 0, $iTimeout =
236
236
SetError (__WD_Error($sFuncName , $iErr ))
237
237
Return $iResult
238
238
EndFunc
239
+
240
+
241
+ ; #FUNCTION# ====================================================================================================================
242
+ ; Name ..........: _WD_GetMouseElement
243
+ ; Description ...: Retrieves reference to element below mouse pointer
244
+ ; Syntax ........: _WD_GetMouseElement($sSession)
245
+ ; Parameters ....: $sSession - Session ID from _WDCreateSession
246
+ ; Return values .: Element ID returned by web driver
247
+ ; Author ........: Dan Pollak
248
+ ; Modified ......:
249
+ ; Remarks .......:
250
+ ; Related .......:
251
+ ; Link ..........: https://stackoverflow.com/questions/24538450/get-element-currently-under-mouse-without-using-mouse-events
252
+ ; Example .......: No
253
+ ; ===============================================================================================================================
254
+ Func _WD_GetMouseElement($sSession )
255
+ Local $sResponse , $sJSON , $sElement
256
+ Local $sScript = " return Array.from(document.querySelectorAll(':hover')).pop()"
257
+
258
+ $sResponse = _WD_ExecuteScript($sSession , $sScript , ' ' )
259
+ $sJSON = Json_Decode($sResponse )
260
+ $sElement = Json_Get($sJSON , " [value][ELEMENT]" )
261
+
262
+ Return $sElement
263
+ EndFunc
264
+
265
+
266
+ ; #FUNCTION# ====================================================================================================================
267
+ ; Name ..........: _WD_GetElementFromPoint
268
+ ; Description ...:
269
+ ; Syntax ........: _WD_GetElementFromPoint($sSession, $iX, $iY)
270
+ ; Parameters ....: $sSession - Session ID from _WDCreateSession
271
+ ; $iX - an integer value.
272
+ ; $iY - an integer value.
273
+ ; Return values .: Success - Element ID returned by web driver
274
+ ; Failure - blank string
275
+ ; Author ........: Dan Pollak
276
+ ; Modified ......:
277
+ ; Remarks .......:
278
+ ; Related .......:
279
+ ; Link ..........:
280
+ ; Example .......: No
281
+ ; ===============================================================================================================================
282
+ Func _WD_GetElementFromPoint($sSession , $iX , $iY )
283
+ Local $sResponse , $sElement , $sJSON
284
+ Local $sScript = " return document.elementFromPoint(arguments[0], arguments[1]);"
285
+ Local $sParams = $iX & " , " & $iY
286
+
287
+ $sResponse = _WD_ExecuteScript($sSession , $sScript , $sParams )
288
+ $sJSON = Json_Decode($sResponse )
289
+ $sElement = Json_Get($sJSON , " [value][ELEMENT]" )
290
+
291
+ Return $sElement
292
+ EndFunc
0 commit comments