You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With SeleniumVBA version 3.5, the ActiveX DLL can be used without registration using API declarations to instantiate the class objects late-bound, just like one would with using Windows API functions. Of course using an unregistered copy of the DLL in this manner would not be the recommended practice if one wants the benefits of IntelliSense and the Object browser in the VBA IDE. But just to illustrate the possibilities...
First we need to setup the declare section for the Class constructors and Enums in a Standard module in your project:
'These declarations are the Class constructors'Make sure to substitute [Path to DLL Folder]\SeleniumVBA_win64.dll with the full path to the unregistered copy of the DLLOption ExplicitPublicDeclarePtrSafeFunctionNew_WebDriverLib "[PathtoDLL]\SeleniumVBA_win64.dll" () AsObjectPublicDeclarePtrSafeFunctionNew_WebElementsLib "[PathtoDLL]\SeleniumVBA_win64.dll" () AsObjectPublicDeclarePtrSafeFunctionNew_WebCookieLib "[PathtoDLL]\SeleniumVBA_win64.dll" () AsObjectPublicDeclarePtrSafeFunctionNew_WebPrintSettingsLib "[PathtoDLL]\SeleniumVBA_win64.dll" () AsObjectPublicDeclarePtrSafeFunctionNew_New_WebJsonConverterLib "[PathtoDLL]\SeleniumVBA_win64.dll" () AsObjectPublicDeclarePtrSafeFunctionNew_WebKeyboardLib "[PathtoDLL]\SeleniumVBA_win64.dll" () AsObjectPublicDeclarePtrSafeFunctionNew_WebDriverManagerLib "[PathtoDLL]\SeleniumVBA_win64.dll" () AsObject'Next, we declare the Enums...PublicEnum By
ID = 0
TagName = 1
ClassName = 2
Name = 3
CssSelector = 4
XPath = 5
LinkText = 6
PartialLinkText = 7End EnumPublicEnum ScrollIntoViewOptions_speed
jump_smooth = 1
jump_instant = 2
jump_auto = 3End EnumPublicEnum ScrollIntoViewOptions_alignment
align_start = 1
align_center = 2
align_end = 3
align_nearest = 4End EnumPublicEnum svbaWindowType
svbaWindow = 0
svbaTab = 1End EnumPublicEnum svbaCompatibility
svbaNotCompatible = 0
svbaMajor = 1
svbaMinor = 2
svbaBuildMajor = 3
svbaExactMatch = 4End EnumPublicEnum svbaBrowser
Chrome = 1
Edge = 2
Firefox = 3
IE = 4End EnumPublicEnum svbaPlatform
svbaSystem = 0
svbaWin32 = 1
svbaWin64 = 2End EnumPublicEnum svbaChannel
svbaStable = 0
svbaBeta = 1
svbaDev = 2
svbaCanary = 3End EnumPublicEnum svbaAlertHandling
svbaAccept
svbaDismiss
svbaIgnore
svbaDismissAndNotify
svbaAcceptAndNotify
End EnumPublicEnum svbaOrientation
svbaLandscape = 0
svbaPortrait = 1End EnumPublicEnum svbaUnits
svbaCentimeters = 0
svbaInches = 1End EnumPublicEnum VBAcolors
Unchanged = -1
Black = VBA.ColorConstants.vbBlack
Blue = VBA.ColorConstants.vbBlue
Cyan = VBA.ColorConstants.vbCyan
Green = VBA.ColorConstants.vbGreen
Magenta = VBA.ColorConstants.vbMagenta
Red = VBA.ColorConstants.vbRed
Yellow = VBA.ColorConstants.vbYellow
End Enum
Unfortunately, I could not find a way to define [Path to DLL Folder] in above code as a single constant - API function declares only except string literals for the full path of an unregistered DLL, so the path must be specified for each declaration.
Once you have the declarations and enums, then the rest is straight forward:
Subtest_sendkeys()
Dim driver AsObjectDim keys AsObjectDim keySeq AsStringSet driver = New_WebDriver
Set keys = New_WebKeyboard
driver.StartEdge
driver.OpenBrowser
driver.NavigateTo "https://www.wikipedia.org/"
driver.Wait 1000
keySeq = "Leonardo da VinJci" & keys.LeftKey & keys.LeftKey & keys.LeftKey & keys.DeleteKey & keys.ReturnKey
driver.FindElement(By.ID, "searchInput").SendKeys keySeq
driver.Wait 1500
driver.CloseBrowser
driver.Shutdown
End Sub
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
With SeleniumVBA version 3.5, the ActiveX DLL can be used without registration using API declarations to instantiate the class objects late-bound, just like one would with using Windows API functions. Of course using an unregistered copy of the DLL in this manner would not be the recommended practice if one wants the benefits of IntelliSense and the Object browser in the VBA IDE. But just to illustrate the possibilities...
First we need to setup the declare section for the Class constructors and Enums in a Standard module in your project:
Unfortunately, I could not find a way to define [Path to DLL Folder] in above code as a single constant - API function declares only except string literals for the full path of an unregistered DLL, so the path must be specified for each declaration.
Once you have the declarations and enums, then the rest is straight forward:
For a complete example set, see the no_registration folder in the repo.
Beta Was this translation helpful? Give feedback.
All reactions