Skip to content

Commit 98afa38

Browse files
authored
Fixes (#13)
- Changed: Force command parameter to lowercase in _WD_Action - Changed: Enhanced error checking in _WD_FindElement
1 parent 9d8d589 commit 98afa38

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

wd_core.au3

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,8 @@ Func _WD_Action($sSession, $sCommand, $sOption = '')
393393
Local Const $sFuncName = "_WD_Action"
394394
Local $sResponse, $sResult = "", $iErr, $sJSON, $sURL
395395

396-
$sURL = $_WD_BASE_URL & ":" & $_WD_PORT & "/session/" & $sSession & "/" & $sCommand
397396
$sCommand = StringLower($sCommand)
397+
$sURL = $_WD_BASE_URL & ":" & $_WD_PORT & "/session/" & $sSession & "/" & $sCommand
398398

399399
Switch $sCommand
400400
Case 'back', 'forward', 'refresh'
@@ -607,14 +607,19 @@ Func _WD_FindElement($sSession, $sStrategy, $sSelector, $sStartElement = "", $lM
607607

608608
$oJson = Json_Decode($sResponse)
609609
$oValues = Json_Get($oJson, '[value]')
610-
$sKey = "[" & Json_ObjGetKeys($oValues[0])[0] & "]"
611610

612-
Dim $aElements[UBound($oValues)]
611+
If UBound($oValues) > 0 Then
612+
$sKey = "[" & Json_ObjGetKeys($oValues[0])[0] & "]"
613+
614+
Dim $aElements[UBound($oValues)]
613615

614-
For $oValue In $oValues
615-
$aElements[$iRow] = Json_Get($oValue, $sKey)
616-
$iRow += 1
617-
Next
616+
For $oValue In $oValues
617+
$aElements[$iRow] = Json_Get($oValue, $sKey)
618+
$iRow += 1
619+
Next
620+
Else
621+
$iErr = $_WD_ERROR_NoMatch
622+
EndIf
618623
Else
619624
$oJson = Json_Decode($sResponse)
620625
$Obj2 = Json_Get($oJson, "[value]")

0 commit comments

Comments
 (0)