pub struct Control {
pub pid: u32,
pub service: String,
pub log_path: PathBuf,
/* private fields */
}Fields§
§pid: u32§service: Stringrightkit-daemon name the app serves (control-xxxxxxxx).
log_path: PathBufImplementations§
Source§impl Control
impl Control
Sourcepub fn assert_no_permission_dialog(&self) -> Result<()>
pub fn assert_no_permission_dialog(&self) -> Result<()>
Fail when a system permission dialog is known to be showing for this app. TODO: the
automation layer cannot enumerate windows by owner (UserNotificationCenter,
CoreServicesUIAgent), so this is a no-op that returns Ok today; see
crate::userdata::live_permission_dialog_check. Use
StopReport::permission_dialog for the evidence that does exist.
pub fn set_request_timeout(&mut self, t: Duration)
Sourcepub fn set_pace_ms(&mut self, ms: u64)
pub fn set_pace_ms(&mut self, ms: u64)
Gap between native input events the app inserts (default 0, no gap). Also set from
RIGHTKIT_QA_PACE_MS at launch. The former fixed pauses were about click 40-50, drag 16,
key 20, type 8 ms; use this for a page that needs real time between events.
Sourcepub fn batch(&self, steps: &[(&str, Value)]) -> Result<Vec<Value>>
pub fn batch(&self, steps: &[(&str, Value)]) -> Result<Vec<Value>>
Run steps ((method, params)) in ONE round trip, stopping at the first failure. Every step is
checked against this app’s allowlist and passes the effect gate and input lease on its own.
Returns each step’s result; the error names the failing step. A batch is never replayed.
pub fn health(&self) -> Result<Value>
Sourcepub fn set_viewport(&self, width: u32, height: u32) -> Result<(u32, u32)>
pub fn set_viewport(&self, width: u32, height: u32) -> Result<(u32, u32)>
Resize hidden native content without screen clamping or activation. Waits for two matching page measurements 500 ms apart, after shell placement. Returns measured CSS dimensions; Windows or visible windows may report OS size limits. Unsettled sizes or placement timeouts are errors; this effect is never replayed.
Sourcepub fn focus_window(&self) -> Result<Value>
pub fn focus_window(&self) -> Result<Value>
Make the window key and focused (see LaunchSpec::focus). Opt-in; also callable mid-run.
Sourcepub fn focus_requested(&self) -> bool
pub fn focus_requested(&self) -> bool
True when this launch asked for a key/focused window, so the never-frontmost proof does not apply.
Sourcepub fn unlisted_app_probe(&self) -> Result<String>
pub fn unlisted_app_probe(&self) -> Result<String>
Prove the allowlist: an app that is not on it is refused at hello. Returns the error code.
pub fn click(&self, x: f64, y: f64, button: &str, count: u32) -> Result<()>
Sourcepub fn click_with(
&self,
x: f64,
y: f64,
button: &str,
count: u32,
modifiers: &[&str],
) -> Result<()>
pub fn click_with( &self, x: f64, y: f64, button: &str, count: u32, modifiers: &[&str], ) -> Result<()>
click holding modifiers ("shift", "cmd", "alt", "ctrl"). They
travel on the native mouse events, so the page sees e.shiftKey etc. as real input.
pub fn move_to(&self, x: f64, y: f64) -> Result<()>
Sourcepub fn pointer(
&self,
phase: &str,
x: f64,
y: f64,
button: &str,
modifiers: &[&str],
) -> Result<()>
pub fn pointer( &self, phase: &str, x: f64, y: f64, button: &str, modifiers: &[&str], ) -> Result<()>
One native pointer phase (down, drag, up, move) in viewport CSS
pixels. Use down/drag/up for a scrub split across requests; keep the same
button and modifiers on each phase. Hidden launches use the embedded path.
pub fn drag(&self, from: (f64, f64), to: (f64, f64), steps: u32) -> Result<()>
pub fn wheel(&self, x: f64, y: f64, dx: f64, dy: f64) -> Result<()>
pub fn key(&self, spec: &str) -> Result<()>
pub fn type_text(&self, text: &str) -> Result<()>
Sourcepub fn eval(&self, js: &str) -> Result<Value>
pub fn eval(&self, js: &str) -> Result<Value>
Evaluate a JS function body (return ...) in the page; returns its JSON value.
pub fn dom(&self, selector: &str) -> Result<Vec<Value>>
pub fn ax(&self) -> Result<Vec<Value>>
pub fn screenshot_png(&self) -> Result<Vec<u8>>
pub fn screenshot_to(&self, path: &Path) -> Result<()>
Sourcepub fn command(&self, name: &str, args: &Value) -> Result<Value>
pub fn command(&self, name: &str, args: &Value) -> Result<Value>
A typed app command registered with Control::command(name, f). The server
hands the command its args string verbatim.
Sourcepub fn center_of(&self, selector: &str) -> Result<(f64, f64)>
pub fn center_of(&self, selector: &str) -> Result<(f64, f64)>
Centre of the first element matching selector, in viewport CSS px.
pub fn click_selector(&self, selector: &str) -> Result<()>
Sourcepub fn click_until(
&self,
selector: &str,
done_js: &str,
attempts: u32,
wait: Duration,
) -> Result<Value>
pub fn click_until( &self, selector: &str, done_js: &str, attempts: u32, wait: Duration, ) -> Result<Value>
Click selector, then wait for done_js (a JS body, see Control::wait_eval) to become
truthy; when the wait times out, click again. For controls that drop the first click
(an unfocused window, a control still mounting). Gives up after attempts clicks.
Sourcepub fn live_log_path(&self) -> &Path
pub fn live_log_path(&self) -> &Path
The live app log (stdout and stderr) while the app runs. Control::stop copies it into
the evidence directory; this path is the source.
Sourcepub fn log_tail(&self, max_chars: usize) -> String
pub fn log_tail(&self, max_chars: usize) -> String
The last max_chars bytes of the live app log (empty when it is unreadable).
Sourcepub fn record_page_errors(&self) -> Result<()>
pub fn record_page_errors(&self) -> Result<()>
Start recording uncaught page errors and unhandled promise rejections into
window.__rkPageErrors. Idempotent. Errors raised before this call are not recorded.
Sourcepub fn page_errors(&self) -> Result<Vec<Value>>
pub fn page_errors(&self) -> Result<Vec<Value>>
Page errors recorded by Control::record_page_errors, oldest first.
Sourcepub fn failure_evidence(
&self,
dir: &Path,
label: &str,
screenshot: bool,
) -> Result<PathBuf>
pub fn failure_evidence( &self, dir: &Path, label: &str, screenshot: bool, ) -> Result<PathBuf>
Failure evidence for a scenario, written to dir/<label>-failure.json: the page URL, the
recorded page errors, the live log tail and, when screenshot is true, a PNG next to it.
Pass screenshot = false in a functional run: a capture is refused there. Returns the JSON path.
Sourcepub fn wait_eval(&self, js: &str, timeout: Duration) -> Result<Value>
pub fn wait_eval(&self, js: &str, timeout: Duration) -> Result<Value>
Wait until a JS function body returns something truthy; bounded. One round trip: the app
waits in the page (DOM mutations, events, a short timer) and replies the moment it holds.
An app on an older driver without the wait method is polled every 25 ms instead.
Sourcepub fn wait_for_text(
&self,
selector: Option<&str>,
text: &str,
timeout: Duration,
) -> Result<()>
pub fn wait_for_text( &self, selector: Option<&str>, text: &str, timeout: Duration, ) -> Result<()>
Wait until text appears in the visible text (innerText) of the first element
matching selector (None = the whole body); see wait_eval.
Sourcepub fn stop(&mut self) -> Result<StopReport>
pub fn stop(&mut self) -> Result<StopReport>
Stop the app: kill the recorded pid tree, prove the port closed, and check we did not change the frontmost app.