Skip to content

Modify Method. Execute #25

Open
Open
@ghost

Description

TinySeleniumVBA WebDriver.cls

Timeout系のCMDを通すために、CMDのPathにtimeoutがある場合、sessionIDを削除する必要がありました。
下記の Execute は、その処置を加えたものです。
TinySeleniumVBA v0.1.0 or v0.1.1 の WebDriver.cls の Execute関数を置き換えて下さい。

' Execute driver command
Public Function Execute(driverCommand, _
                        Optional parameters As Dictionary = Nothing)
    Dim method As String: method = driverCommand(0)
    Dim path As String: path = driverCommand(1)
    If parameters Is Nothing Then
        Set parameters = New Dictionary
    End If
    
    ' Set default session id if session id is missing
    If Not parameters.Exists("sessionId") Then
        parameters.Add "sessionId", DefaultSessionId
    End If
    
    ' Set params to path
    Dim paramKey As Variant
    For Each paramKey In parameters
        If VarType(parameters(paramKey)) = vbString Then
            path = Replace(path, "$" + paramKey, parameters(paramKey))
        End If
    Next
    
    ' Remove sessionID, if timeouts in path     '2021/7/14 chg ishi
    If InStr(path, "timeouts") > 0 Then
        If parameters.Exists("sessionId") Then
            parameters.Remove "sessionId"
        End If
    End If

    ' Send request to selenium server
    Dim resp As Dictionary
    Set resp = SendRequest(method, UrlBase + path, parameters)
    
    ' Return value(s)
    If IsNull(resp("value")) Then
        Set Execute = New Dictionary
    ElseIf TypeName(resp("value")) = "Collection" Then
        Set Execute = resp("value")
    ElseIf VarType(resp("value")) = vbObject Then
        If resp("value").Exists("error") Then
            Err.Raise 513, "WebDriver.Execute", JsonConverter.ConvertToJson(resp("value"))
        Else
            Set Execute = resp("value")
        End If
    Else
        Execute = resp("value")
    End If
End Function

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions