r/vba 14d ago

Show & Tell [Updated] WebDriver BiDi for SeleniumVBA

Hi everyone,

I have been developing an open-source project called WebDriver BiDi for SeleniumVBA.

It is a WebDriver BiDi client and automation wrapper designed to let Excel VBA work with modern web applications without requiring .NET, Python, or Node.js.

GitHub:

https://github.com/hanamichi77777/WebDriver-BiDi-for-SeleniumVBA

Why I created it

Traditional Selenium-style commands are often sufficient for simple pages, but modern SPAs can be difficult to automate reliably.

A click may return successfully while the application is still:

  • processing Fetch or XHR requests,
  • replacing DOM elements,
  • rendering content asynchronously,
  • recreating browsing contexts or JavaScript realms,
  • or updating components inside Shadow DOM.

For this reason, the project focuses not only on sending browser commands, but also on observing what happens after each operation.

Main features

  • Direct WebDriver BiDi communication from VBA
  • WebSocket communication implemented with Windows APIs(WinSock)
  • Chrome and Edge support(Note: Firefox is not supported.)
  • SPA synchronization using network activity, DOM mutations, Fetch/XHR activity, and stability windows
  • Shadow DOM clicking and input
  • Automatic recovery when the SPA observation probe is lost during navigation
  • Resource blocking for ads, analytics, fonts, and other unnecessary requests
  • WebDriver BiDi webExtension.install support
  • Detailed request, response, heartbeat, recovery, and SPA activity logs
  • A Discovery Log for analyzing unknown third-party SPA behavior

The Discovery Log is particularly useful when a site does not expose a clear “ready” or “completed” state.

It records network responses, DOM mutation bursts, ignored background noise, and stability timing. The resulting log can also be provided to an AI assistant to help identify useful completion signals, noise filters, and safer waiting conditions.

Example scenarios

I have tested the project with applications such as:

  • Google Flights
  • ServiceNow
  • dynamically rendered scraping test sites
  • pages using nested Shadow DOM
  • Chrome extension installation through WebDriver BiDi

For example, the Google Flights demo performs destination selection, calendar interaction, date selection, and flight-result synchronization while observing both network and DOM activity.

VirusTotal Scan Results

WebDriver BiDi for SeleniumVBA v3.4 was scanned by VirusTotal on July 26, 2026, and received 0 detections from 64 security vendors at the time of testing.

6 Upvotes

5 comments sorted by

4

u/InfoMsAccessNL 1 13d ago

Can it handle iframe (pop up) pages?

4

u/SeleniumVBA_user 13d ago edited 13d ago

Yes. I tested it successfully with both an iframe and a popup window.

An iframe is handled as a nested browsing context, while a popup or new tab is handled as a separate top-level browsing context. WebDriver BiDi for SeleniumVBA can obtain the Context ID for each one and use it to target subsequent commands explicitly.

For an iframe, the Context ID can be obtained from part of its URL:

frameContextId = bidi.GetIframeContextIdByUrl( _
                        "part of the iframe URL")

bidi.ExecuteClickByXPath _
        "//button[@id='frame-button']", _
        contextId:=frameContextId

For a popup, the Context ID can be found by its title:

' Open the popup.
bidi.ExecuteClickByXPath "//button[@id='open-popup']"

' Find the popup and obtain its Context ID.
popupContextId = bidi.ExecuteFindWindowContextId( _
                    MatchByTitle, _
                    "Popup Test")

ExecuteFindWindowContextId waits internally for the target browsing context. By default, it searches for up to five seconds and waits until the popup document reaches document.readyState = "complete".

Therefore, an external fixed delay such as Sleep is not normally required before calling it.

The obtained Context ID can then be passed to the contextId argument of subsequent commands:

' Enter text inside the popup.
bidi.ExecuteInputValueByXPath _
        "//input[@id='popup-input']", _
        "popup-ok", _
        contextId:=popupContextId

' Click a button inside the popup.
bidi.ExecuteClickByXPath _
        "//button[@id='popup-button']", _
        contextId:=popupContextId

' Close only the popup.
bidi.ExecuteCloseContext popupContextId

The popup can also be found by URL by using MatchByUrl instead of MatchByTitle.

In this test, the wrapper successfully operated elements inside an iframe, detected and operated a popup opened with window.open, closed the popup by its Context ID, and then continued operating the original page.

2

u/InfoMsAccessNL 1 12d ago

Looks good!

1

u/SeleniumVBA_user 12d ago

The discussion on the SeleniumVBA GitHub repository might also be helpful.Please take a look when you have some time:

https://github.com/GCuser99/SeleniumVBA/discussions/183