' Set Focus
Public Function Focus(ByVal ElementId As String, _
Optional ByVal sessionId As String = vbNullString)
Dim Script As String
Script = "arguments[0].focus({'preventScroll': arguments[1]})"
ExecuteScript Script, 0, ElementId, sessionId 'Scroll
End Function
' Set Focus No Scroll
Public Function FocusNoScroll(ByVal ElementId As String, _
Optional ByVal sessionId As String = vbNullString)
Dim Script As String
Script = "arguments[0].focus({'preventScroll': arguments[1]})"
ExecuteScript Script, 1, ElementId, sessionId 'No Scroll
End Function
WebElement.cls
' Set Focus '2021/7/10 add ishi
Public Sub Focus()
Driver_.Focus ElementId_, SessionId_
End Sub
' Set Focus No Scroll '2021/7/10 add ishi
Public Sub FocusNoScroll()
Driver_.FocusNoScroll ElementId_, SessionId_
End Sub
Scroll operations
WebDriver.cls
' Scroll By Element
Public Function ScrollByElement(ByVal ElementId As String, _
Optional ByVal Offset As Integer = 0, _
Optional ByVal sessionId As String = vbNullString)
Dim Script As String
Script = "arguments[0].scrollIntoView();"
ExecuteScript Script, ElementId, ElementId, sessionId
If Offset <> 0 Then
Script = "window.scrollTo(0, window.pageYOffset + " & CStr(Offset) & ");"
ExecuteScript Script, ElementId, ElementId, sessionId
End If
End Function
WebElement.cls
' Scroll By Element
Public Function ScrollByElement(Optional ByVal Offset As Integer = 0)
Driver_.ScrollByElement ElementId_, Offset, SessionId_
End Function
Focus operations WebDriver.cls
WebElement.cls
Scroll operations WebDriver.cls
WebElement.cls