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 Wait Method #71

Open
yaju opened this issue May 28, 2022 · 0 comments
Open

Add Wait Method #71

yaju opened this issue May 28, 2022 · 0 comments

Comments

@yaju
Copy link

yaju commented May 28, 2022

I want to add Wait Method.(SeleniumVBA's TimerWait Method)

Public Sub Wait(Optional ByVal milliseconds As Long = 300)
    'pause in milliseconds
    Dim startTime As Single, endTime As Single, nowTime As Single, elapsedTime As Single
    startTime = VBA.Timer()
    endTime = startTime + milliseconds / 1000#
    Do While nowTime < endTime
        nowTime = VBA.Timer()
        If nowTime < startTime Then 'oops - someone is burning the midnight oil!
            endTime = endTime - elapsedTime
            startTime = 0
        End If
        elapsedTime = nowTime - startTime
        DoEvents    'yield to other processes.
    Loop
End Sub

It also worked on Mac.

Debug.Print Now
Driver.Wait 5000
Debug.Print Now

’2022/05/28 21:24:02 
’2022/05/28 21:24:07 

In relation to the timer.
Previously, when I added SetPageLoadTimeout, I got the following error.
Error 513 「invalid argument value must be a non-negative integer」
https://qiita.com/yaju/items/9d1f189a5d2118a3f4d3#comment-66636c3d7ded6b6e14de

I modified it by referring to SeleniumVBA's Execute Method,

Public Function Execute

    ' Set params to path
    Dim cmdArgs As New Dictionary
    Dim paramKey As Variant
    For Each paramKey In parameters.Keys
        If InStr(path, "$" & paramKey) > 0 Then 'path parameter
            path = Replace(path, "$" & paramKey, parameters(paramKey))
        Else 'non-path parameter
            cmdArgs.Add paramKey, parameters(paramKey)
        End If
    Next

    If cmdArgs.Exists("sessionId") Then cmdArgs.Remove "sessionId"
    
    ' Send request to selenium server
    Dim resp As Dictionary
    Set resp = SendRequest(method, UrlBase + path, cmdArgs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant