Skip to content

Commit 8351ca7

Browse files
committed
Added _WD_NewTab helper function
1 parent c27cd5c commit 8351ca7

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

webdriver.au3

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,37 @@ Func _WDShutdown()
923923
EndFunc
924924

925925

926+
; #FUNCTION# ====================================================================================================================
927+
; Name ..........: _WD_NewTab
928+
; Syntax ........: _WD_NewTab($sSession[, $lSwitch = True])
929+
; Parameters ....: $sSession - Session ID from _WDCreateSession
930+
; $lSwitch - [optional] Switch session context to new tab? Default is True.
931+
; Return values .: String representing handle of new tab
932+
; Author ........: Dan Pollak
933+
; Modified ......:
934+
; Remarks .......:
935+
; Related .......:
936+
; Link ..........:
937+
; Example .......: No
938+
; ===============================================================================================================================
939+
Func _WD_NewTab($sSession, $lSwitch = True)
940+
Local $sTabHandle = ''
941+
942+
_WDExecuteScript($sSession, 'window.open()', '{}')
943+
944+
If @error = $_WD_ERROR_Success Then
945+
Local $aHandles = _WDWindow($sSession, 'handles', '')
946+
947+
$sTabHandle = $aHandles[UBound($aHandles) - 1]
948+
949+
If $lSwitch Then
950+
_WDWindow($sSession, 'Switch', '{"handle":"' & $sTabHandle & '"}')
951+
EndIf
952+
EndIf
953+
954+
Return $sTabHandle
955+
EndFunc
956+
926957
; #INTERNAL_USE_ONLY# ===========================================================================================================
927958
; Name ..........: __WD_Get
928959
; Description ...: Submit GET request to WD console app

0 commit comments

Comments
 (0)