Repository navigation
seleniumbase-rs 0.4.0
A feature release: browser plugins now run in the WebDriver engine as well as
the Pure CDP one, the Pure CDP engine gains page script and style tags and HAR
recording, the opt-in visual feature compares screenshots by structural
similarity, sbrs prompt prints a browser and driver segment for shell prompts,
and the documentation gains a guide to testing pages with a CAPTCHA.
Added
- Browser plugins for the WebDriver engine (feature
plugins; ADR 004
phase 3).BrowserConfig::with_pluginsgives aPluginSetto
BaseCase::newandBrowserSession::connect: the set is checked against the
browser,before_launchchanges the start-up settings (Chromium arguments,
capability preferences, extension folders, proxy and headless; Firefox
arguments, preferences and headless), and once the session runs the plugins
geton_browser, then the packages andon_page_createdfor the first
window, for each windowswitch_to_new_windoworopen_new_windowopens, and
for any other onapply_plugins_to_window;quitor a drop calls
on_close, andreconnectruns the hooks again. On Chromium browsers
plugins send protocol commands through chromedriver's DevTools channel; on
Firefox and Safarisendis refused and scripts for every document run at
once and again after eachopen. A refusal or a failing hook stops the
session withSeleniumBaseError::Plugin. Plugins withreuse_sessionare
refused. See the WebDriver section ofdocs/tutorials/plugins.md. sb_cdp::Page::add_script_tagandadd_style_tagadd a script or a
stylesheet to the current document from a URL or inline (TagSource),
waiting for a file to load;add_init_scriptruns a script in every
document the tab loads from then on and returns anInitScriptIdfor
remove_init_script. Playwright'saddScriptTag,addStyleTagand
addInitScript.- With the
pluginsfeature,sb_cdp::Pageimplements the plugin API's
PageHandle, so a program can hand one of its tabs to plugin code. - Visual regression testing, behind the new opt-in
visualfeature:
visual::VisualBaselinesaves a screenshot as a baseline PNG on the first
run and compares later screenshots with it by structural similarity (MSSIM
over 8 × 8 windows on each colour channel,image-compare), failing below a
threshold of 0.999 withAssertionFailedand leaving<name>.actual.pngand
a<name>.diff.pngthat paints the differences red. Screenshots of another
size fail without a comparison.check_pagetakes aBaseCaseor an
sb_cdp::Page, andBaseCase::assert_visual_match(name)keeps its baselines
invisual_baseline/<test>/,<test>being the test's whole path (test
binary, module path and function, ascart.checkout.renders), and follows
with_visual_baseline_reset.
check_windowis unchanged: it compares the HTML layout, as in Python. - HAR recording for the pure CDP engine (no new dependency, no feature):
Page::start_har()/start_har_with(HarOptions)return aHarRecorder,
andHarRecorder::finish()returns aHar(HTTP Archive 1.2 serde types)
thatHar::save(path)writes as JSON. Entries come from theNetwork
events of the tab and of its cross-site iframes, which run in targets of
their own and are attached while recording, extra-info headers included, with cookies, query strings, POST
bodies, one entry per redirect hop, failures with Chrome's_error, and
blocked/dns/connect/ssl/send/wait/receivetimings; each
top-level navigation is a page withonContentLoadandonLoad. Response
bodies are off by default and capped at 1 MiB each when turned on; the cap
can be raised to 64 MiB (MAX_CONTENT_BYTES). sbrs promptprints one short line for a shell prompt: the installed
Chrome's major version and whether a matching chromedriver is at hand
(chrome 155 ✓driver,✗driver,?driver), with--asciimarks and a
--formatof{browser},{major},{driver},{mark}and
{driver_major}. It starts no browser and uses no network: versions come
from files (a macOS app'sInfo.plist, the version folder beside
chrome.exe), and one that only--versiontells is cached for ten minutes
in the user cache folder. It prints nothing and exits with 0 when no browser
is found (--verbosesays why). The CLI page has setups for Bash, Zsh,
Fish, PowerShell, Starship and Warp, and.warp/workflows/a Workflow for it.browser::driver_version::major_without_runningreads a program's major
version from its files only, andversion_flag_majorruns--versionwith a
time limit.- Tutorial Testing Pages with a CAPTCHA: vendor test keys, and tests that click the test widget and read the token.
docs/completions/: a Fig completion spec forsbrs, prepared for withfig/autocomplete (not submitted), with the steps.
Fixed
- The pure CDP engine takes DevTools messages up to 256 MiB, as Puppeteer
does. Chrome sends each answer in one WebSocket frame, and one over the
default 16 MiB, such as a large screenshot or response body, used to close
the connection for every tab. sbrsexits quietly with status 0 when the reader of its output goes away
(sbrs completions zsh | head), instead of printing "error: Broken pipe".