Skip to content

Commit 585910c

Browse files
authored
_WD_GetElementFromPoint: Detect invalid coordinates (#490)
1 parent f0bc24d commit 585910c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Go to [legend](#legend---types-of-changes) for further information about the typ
1717
- Support for non-standard table markers
1818
- Improve performance
1919

20+
- _WD_GetElementFromPoint: Added error checking for negative coordinates
21+
2022
### Fixed
2123

2224
- _WD_GetTable: Revise existing xpaths to include header elements in results

wd_helper.au3

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,9 @@ EndFunc ;==>_WD_GetMouseElement
600600
; $iX - an integer value
601601
; $iY - an integer value
602602
; Return values .: Success - Element ID returned by web driver.
603-
; Failure - "" (empty string) and @error is set to $_WD_ERROR_RetValue
603+
; Failure - "" (empty string) and @error is set to one of the following values:
604+
; - $_WD_ERROR_RetValue
605+
; - $_WD_ERROR_InvalidArgue
604606
; Author ........: Danp2
605607
; Modified ......: mLipok
606608
; Remarks .......: @extended is set to 1 if the browsing context changed during the function call
@@ -617,7 +619,14 @@ Func _WD_GetElementFromPoint($sSession, $iX, $iY)
617619
Local $sScript2 = "return new Array(window.pageXOffset, window.pageYOffset);"
618620
Local $iErr = $_WD_ERROR_Success, $sResult, $bIsNull
619621

620-
While True
622+
; https://developer.mozilla.org/en-US/docs/Web/API/Document/elementFromPoint
623+
; If the specified point is outside the visible bounds of the document or either
624+
; coordinate is negative, the result is null
625+
If $iX < 0 Or $iY < 0 Then
626+
$iErr = $_WD_ERROR_InvalidArgue
627+
EndIf
628+
629+
While $iErr = $_WD_ERROR_Success
621630
$sParams = $iX & ", " & $iY
622631
$sResponse = _WD_ExecuteScript($sSession, $sScript1, $sParams)
623632
If @error Then

0 commit comments

Comments
 (0)