Skip to content

Option.cls needs to be renamed if this library is used in Word #6

Closed
@shajvarg

Description

@shajvarg

hi,
thanks once again for all the help.
I have replaced old seleniumvba 2.0.9 lib with this library and it works well.

In word, Option.cls had to be renamed as there is a default option class in word.

I also made a few changes to better control visibility and logging and to mantain compatibilty with old library.

Public Sub Edge(Optional ByVal driverPath As String = "msedgedriver.exe", _
Optional ByVal port As Integer = 9516, Optional ByVal LoggingEnable As Boolean = True, _
Optional vbStyle As VbAppWinStyle = vbHide)
Dim cmdLaunch As String

cmdLaunch = driverPath & " --port=" & CStr(port)
RemoteEndUrl = "http://localhost:" & CStr(port)
PID = Shell(cmdLaunch, vbStyle)
m_SaveLog = LoggingEnable

End Sub

Public Function FindElement(ByVal by_strategy As By, _
ByVal target As String) As WebElement
Dim urlParameters As New Dictionary, _
requestBody As New Dictionary, _
responseBody As Dictionary

urlParameters.Add "{session id}", Capabilities("sessionId")
Set requestBody = SelectLocationStrategies(by_strategy, target)

Set responseBody = SendCommand2Webdriver(W3C_FIND_ELEMENT, urlParameters, requestBody)

If responseBody Is Nothing Then
  Set FindElement = Nothing
Else
  Set FindElement = Convert2WebElement(responseBody("value"))
End If

End Function

the below is in "SendCommand2Webdriver" function
If xmlHttp.Status = 200 Then
Set SendCommand2Webdriver = JsonConverter.ParseJson(xmlHttp.responseText)
Else
If m_SaveLog Then
Log4Driver xmlHttp.responseText
Err.Raise vbObjectError + 513, "WebDriver", xmlHttp.responseText
Else
Set SendCommand2Webdriver = Nothing
End If
End If

Instead of raising Error, it will return nothing as return object like the original lib.

Thanks once again for a great wrapper..

Shaju

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions