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

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

Closed
shajvarg opened this issue Sep 21, 2022 · 2 comments
Closed

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

shajvarg opened this issue Sep 21, 2022 · 2 comments

Comments

@shajvarg
Copy link

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

@er-ri
Copy link
Owner

er-ri commented Sep 26, 2022

I have renamed Option.cls to WebDriverOptions.cls and introduced a new parameter LogFile in WebDriverOptions.cls for the user can specify the log file output path, leave it empty the log file will not be generated. Thank you for the improvements.

er-ri pushed a commit that referenced this issue Sep 26, 2022
@shajvarg
Copy link
Author

Thanks for the update.
Shaju

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

2 participants