All Projects → uezo → TinySeleniumVBA

uezo / TinySeleniumVBA

Licence: MIT license
A tiny Selenium wrapper written in pure VBA

Programming Languages

vba
158 projects

Projects that are alternatives of or similar to TinySeleniumVBA

extensiveautomation-server
Extensive Automation server
Stars: ✭ 19 (-34.48%)
Mutual labels:  selenium
callisto
Callisto is an open-source Kubernetes-native implementation of Selenium Grid.
Stars: ✭ 83 (+186.21%)
Mutual labels:  selenium
VBA-Import-Export
Export & Import VBA code for use with Git (or any VCS)
Stars: ✭ 14 (-51.72%)
Mutual labels:  vba-excel
SeleniumDemo
Selenium automation test framework
Stars: ✭ 84 (+189.66%)
Mutual labels:  selenium
scribd-dl
Command-line program to download Scribd documents in pdf format
Stars: ✭ 23 (-20.69%)
Mutual labels:  selenium
Mobilenium
Mobilenium allows you to use Selenium and have access to status codes and HTTP headers, without the need for manual labor.
Stars: ✭ 22 (-24.14%)
Mutual labels:  selenium
Selenium.HtmlElements.Net
Elements model for Selenium.WebDriver
Stars: ✭ 26 (-10.34%)
Mutual labels:  selenium
YoukuDownload
youku 视频下载
Stars: ✭ 12 (-58.62%)
Mutual labels:  selenium
Selenium-Foundation
Selenium Foundation is an automation framework designed to extend and enhance the capabilities provided by Selenium (WebDriver).
Stars: ✭ 51 (+75.86%)
Mutual labels:  selenium
dusker
Stand alone Laravel Dusk test suit, which do not require Laravel framework itself
Stars: ✭ 28 (-3.45%)
Mutual labels:  selenium
whatsapp-bot
Made with Python and Selenium, can be used to send multiple messages and send messages as characters made of emojis
Stars: ✭ 34 (+17.24%)
Mutual labels:  selenium
Baidu-Index
精准的百度指数抓取
Stars: ✭ 14 (-51.72%)
Mutual labels:  selenium
SWET
Selenium WebDriver Page Test / workflow recorder (successor to SWD recorder)
Stars: ✭ 34 (+17.24%)
Mutual labels:  selenium
Insta-Bot
Python bot using Selenium increasing Instagram Followers.
Stars: ✭ 62 (+113.79%)
Mutual labels:  selenium
Instagram-Giveaways-Winner
Instagram Bot which when given a post url will spam mentions to increase the chances of winning. Win Instagram Giveaways!
Stars: ✭ 95 (+227.59%)
Mutual labels:  selenium
selenium-openapi
The missing Selenium OpenAPI spec
Stars: ✭ 25 (-13.79%)
Mutual labels:  selenium
InstagramLocationScraper
No description or website provided.
Stars: ✭ 13 (-55.17%)
Mutual labels:  selenium
selenium-grid-docker-swarm-test
Distribute automated tests with Selenium Grid and Docker Swarm
Stars: ✭ 28 (-3.45%)
Mutual labels:  selenium
people-also-ask
People also ask Google scraper. Get as many questions as you need to optimize your site for voice or new content ideas or answering questions about your desired topic.
Stars: ✭ 39 (+34.48%)
Mutual labels:  selenium
Google-DSC-Platform-Extension
Hello DSC Leads, Automate your process of adding attendees manually.
Stars: ✭ 16 (-44.83%)
Mutual labels:  selenium

TinySeleniumVBA

A tiny Selenium wrapper written in pure VBA.

🇯🇵日本語のREADMEはこちら

🇧🇷Versão em Português

Features

  • No installation: Everyone even who doesn't have permissions to install can automate browser operations.
  • Useful helper Methods: FindElement(s)By*, Get/Set value to form, click and more.
  • Open spec: Basically this wrapper is just a HTTP client of WebDriver server. Learning this wrapper equals to learning WebDriver. https://www.w3.org/TR/webdriver/

📦 Setup

  1. Set reference to Microsoft Scripting Runtime

  2. Add WebDriver.cls, WebElement.cls, Capabilities.cls and JsonConverter.bas to your VBA Project

  3. Download WebDriver (driver and browser should be the same version)

🪄 Usage

Public Sub main()
    ' Start WebDriver (Edge)
    Dim Driver As New WebDriver
    Driver.Edge "path\to\msedgedriver.exe"

    ' Open browser
    Driver.OpenBrowser
    
    ' Navigate to Google
    Driver.Navigate "https://www.google.co.jp/?q=selenium"

    ' Get search textbox
    Dim searchInput
    Set searchInput = Driver.FindElement(By.Name, "q")
    
    ' Get value from textbox
    Debug.Print searchInput.GetValue
    
    ' Set value to textbox
    searchInput.SetValue "yomoda soba"
    
    ' Click search button
    Driver.FindElement(By.Name, "btnK").Click
    
    ' Refresh - you can use Execute with driver command even if the method is not provided
    Driver.Execute Driver.CMD_REFRESH
End Sub

🐙 BrowserOptions

Use Capabilities to configure browser options. This is an example to launch browser as headless (invisible) mode.

' Start web driver
Dim Driver As New WebDriver
Driver.Chrome "C:\path\to\chromedriver.exe"

' Configure Capabilities
Dim cap As Capabilities
Set cap = Driver.CreateCapabilities()
cap.AddArgument "--headless"
' Use SetArguments if you want to add multiple arguments
' cap.SetArguments "--headless --xxx -xxx"

' Show Capabilities as JSON for debugging
Debug.Print cap.ToJson()

' Open browser
Driver.OpenBrowser cap

See also the sites below to understand the spec of Capabilities for each browser.

⚡️ Execute JavaScript

Use ExecuteScript() to execute JavaScript on the browser.

' Start web driver
Dim Driver As New WebDriver
Driver.Chrome "C:\path\to\chromedriver.exe"

' Open browser
Driver.OpenBrowser

' Navigate to Google
Driver.Navigate "https://www.google.co.jp/?q=liella"

' Show alert
Driver.ExecuteScript "alert('Hello TinySeleniumVBA')"

' === Use breakpoint to CLOSE ALERT before continue ===

' Pass argument
Driver.ExecuteScript "alert('Hello ' + arguments[0] + ' as argument')", Array("TinySeleniumVBA")

' === Use breakpoint to CLOSE ALERT before continue ===

' Pass element as argument
Dim searchInput
Set searchInput = Driver.FindElement(By.Name, "q")
Driver.ExecuteScript "alert('Hello ' + arguments[0].value + ' ' + arguments[1])", Array(searchInput, "TinySeleniumVBA")

' === CLOSE ALERT and continue ===

' Get return value from script
Dim retStr As String
retStr = Driver.ExecuteScript("return 'Value from script'")
Debug.Print retStr

' Get WebElement as return value from script
Dim firstDiv As WebElement
Set firstDiv = Driver.ExecuteScript("return document.getElementsByTagName('div')[0]")
Debug.Print firstDiv.GetText()

' Get complex structure as return value from script
Dim retArray
retArray = Driver.ExecuteScript("return [['a', '1'], {'key1': 'val1', 'key2': document.getElementsByTagName('div'), 'key3': 'val3'}]")

Debug.Print retArray(0)(0)  ' a
Debug.Print retArray(0)(1)  ' 1

Debug.Print retArray(1)("key1") ' val1
Debug.Print retArray(1)("key2")(0).GetText()    ' Inner Text
Debug.Print retArray(1)("key2")(1).GetText()    ' Inner Text
Debug.Print retArray(1)("key3") ' val3

❤️ Thanks

VBA-JSON by Tim Hall, JSON converter for VBA helps me a lot to make HTTP client and this awesome library is included in the release under its license. Thank you!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].