seleniumbase-rs-plugin-testing has recording fakes of PageHandle and
BrowserHandle: they write down every command, script and expression a
plugin sends, so a test checks what a hook did, without a browser. It is in the
plugins repository, crates/seleniumbase-rs-plugin-testing/src/lib.rs, and
depends only on the API crate. To run the real launch steps of seleniumbase-rs
against a scripted browser instead, see the Mock browser tab of
Test it without a browser.
Depend on it#
Take it at the same rev as seleniumbase-rs-plugin, so both name one copy of
the API crate.
Call#
enum seleniumbase_rs_plugin_testing::Call
One thing a plugin asked a fake handle to do. Compare calls() with a list of
them.
RecordingPage#
struct seleniumbase_rs_plugin_testing::RecordingPage
A fake tab that records what a plugin asks of it. Every method of
PageHandle records its call first, then answers:
| Method | Records | Answers |
|---|---|---|
engine() | nothing | the engine it was made with |
send(method, params) | Call::Send(method, params) | the reply set for method, or null |
add_init_script(source) | Call::InitScript(source) | Ok(()) |
evaluate(expression) | Call::Evaluate(expression) | the reply set for "evaluate", or null |
A method made to fail with failing answers
PluginError::Other("METHOD failed (fake)") instead, after recording.
RecordingPage::new#
fnA fake tab of the pure CDP engine (Engine::Cdp); also RecordingPage::default().
RecordingPage::on#
fnThe engine engine() reports, such as Engine::WebDriver.
A fake tab of engine.
RecordingPage::failing#
fnA DevTools method name for send, or "add_init_script" or "evaluate".
The fake, with method answering PluginError::Other("METHOD failed (fake)"). One method fails at a time: a second call replaces the first.
RecordingPage::replying#
fnA DevTools method name for send, or "evaluate".
What it answers. Each method has its own reply; a later one replaces an earlier one.
The fake, with method answering reply (otherwise null).
RecordingPage::calls#
fnEverything the plugins asked for, in order: a copy, so the fake keeps recording.
RecordingBrowser#
struct seleniumbase_rs_plugin_testing::RecordingBrowser
A fake browser that records what a plugin asks of it. engine() and
family() report what it was made with; send(method, params) records
Call::Send(method, params) and answers null. It has no failing or
replying.
RecordingBrowser::new#
fnA fake Chromium browser on the pure CDP engine; also
RecordingBrowser::default().
RecordingBrowser::of#
fnThe engine it reports.
The family it reports, such as BrowserFamily::Firefox.
A fake browser of family on engine.
RecordingBrowser::calls#
fnEverything the plugins asked for, in order.
block_on#
fn seleniumbase_rs_plugin_testing::block_on
A future to run, such as set.on_page_created(&page).
Its output.
Runs a future to completion on the current thread, for tests and examples that
do not want a runtime: it polls with a no-op waker and yields the thread between
polls. The fakes never wait, so nothing else is needed. It drives no I/O and no
timers: a future that needs a runtime’s reactor, such as tokio’s, does not
complete under it. Test those against the mock browser of seleniumbase-rs with
#[tokio::test].