WebView2 Apps¶
WebView2 hosts Microsoft Edge content inside a native Windows application. Dolphin drives the accessibility tree exposed to UIA.
Launch¶
from dolphin_desktop import Desktop
desktop = Desktop()
app = desktop.launch_webview2("MyHybridApp.exe")
win = app.window(title_re=".*My Hybrid App.*")
launch_webview2() is a semantic wrapper around Desktop.launch(). It does not add command-line flags.
Detect WebView2¶
Detection checks for WebView2 loader modules in the process and returns False on errors.
Work With Native And Web Controls¶
Use dolphin spy to see where the WebView document appears:
Example:
# Native host control
win.get_by_automation_id("btnRefresh").click()
# Web content exposed through UIA
doc = win.get_by_role("Document")
doc.get_by_role("Edit", name="Username").type_text("admin")
doc.get_by_role("Button", name="Sign in").click()
If the page loads slowly, use a locator timeout:
Notes¶
- Native controls and embedded web controls may be siblings in the UIA tree.
- Iframes can appear as nested
Documentnodes. - Dolphin does not use DOM selectors or JavaScript injection; it uses Windows accessibility.