Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Method. SwitchToFrame, SwitchToParentFrame, GetCurrentFrame #23

Open
ghost opened this issue Sep 16, 2021 · 2 comments
Open

Add Method. SwitchToFrame, SwitchToParentFrame, GetCurrentFrame #23

ghost opened this issue Sep 16, 2021 · 2 comments
Labels

Comments

@ghost
Copy link

ghost commented Sep 16, 2021

TinySeleniumVBA WebDriver.cls

' ==========================================================================
' Frame operations
' ==========================================================================

' Switch to Frame               '2021/6/17 add ishi
Public Function SwitchToFrame(ElementId As String, _
                              Optional ByVal sessionid As String = vbNullString)
    Dim data    As New Dictionary
    Dim subdata As New Dictionary
    subdata.Add "ELEMENT", ElementId
    subdata.Add ELEMENT_KEY, ElementId
    If sessionid <> vbNullString Then
        subdata.Add "sessionId", sessionid
    End If
    data.Add "id", subdata

    Execute CMD_SWITCH_TO_FRAME, data
End Function

' Switch to Parent Frame        '2021/6/17 add ishi
Public Function SwitchToParentFrame(Optional ByVal sessionid As String = vbNullString)
    Dim data    As New Dictionary
    If sessionid <> vbNullString Then
        data.Add "sessionId", sessionid
    End If

    Execute CMD_SWITCH_TO_PARENT_FRAME, data
End Function

' Get Current Frame             '2021/7/9 add ishi
Public Function GetCurrentFrame(Optional ByVal sessionid As String = vbNullString) As String
    Dim data    As New Dictionary
    data.Add "script", "return self.name"
    Dim args    As Variant
    args = Array()
    data.Add "args", args
    
    If sessionid <> vbNullString Then
        data.Add "sessionId", sessionid
    End If

    GetCurrentFrame = Execute(CMD_W3C_EXECUTE_SCRIPT, data)
End Function

TinySeleniumVBA WebElement.cls

' ==========================================================================
' Frame operations
' ==========================================================================

' Switch to Frame                   '2021/6/22 add ishi
Public Function SwitchToFrame()
    Driver_.SwitchToFrame ElementId_, SessionId_
End Function
@ghost ghost changed the title Method. SwitchToFrame, SwitchToParentFrame, GetCurrentFrame Method. SwitchToFrame, SwitchToParentFrame, GetCurrentFrame Sep 16, 2021
@ghost ghost changed the title Method. SwitchToFrame, SwitchToParentFrame, GetCurrentFrame Add Method. SwitchToFrame, SwitchToParentFrame, GetCurrentFrame Oct 23, 2021
@uezo uezo added the DOM label Dec 30, 2021
@GCuser99
Copy link

GCuser99 commented Dec 31, 2021

Hi @ezagdd - in your WebDriver SwitchToFrame Function, shouldn't the sessionId key be added to data, instead of subdata? For example:

    If sessionid <> vbNullString Then
        data.Add "sessionId", sessionid
    End If

@ghost
Copy link
Author

ghost commented Jan 10, 2022

ありがとう。data に sessionId キー を追加する様に変えて動作確認済。
Thanks. I changed it to add the sessionId key to the data and it works.

Public Function SwitchToFrame(ByVal ElementId As String, _
                              Optional ByVal sessionId As String = vbNullString)
    Dim Data    As New Dictionary
    Dim subdata As New Dictionary
    subdata.Add "ELEMENT", ElementId
    subdata.Add ELEMENT_KEY, ElementId
    If sessionId <> vbNullString Then
        Data.Add "sessionId", sessionId
    End If
    Data.Add "id", subdata

    Execute CMD_SWITCH_TO_FRAME, Data
End Function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants