Skip to main content

Control

Struct Control 

Source
pub struct Control {
    pub pid: u32,
    pub service: String,
    pub log_path: PathBuf,
    /* private fields */
}

Fields§

§pid: u32§service: String

rightkit-daemon name the app serves (control-xxxxxxxx).

§log_path: PathBuf

Implementations§

Source§

impl Control

Source

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.

Source

pub fn set_request_timeout(&mut self, t: Duration)

Source

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.

Source

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.

Source

pub fn health(&self) -> Result<Value>

Source

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.

Source

pub fn focus_window(&self) -> Result<Value>

Make the window key and focused (see LaunchSpec::focus). Opt-in; also callable mid-run.

Source

pub fn focus_requested(&self) -> bool

True when this launch asked for a key/focused window, so the never-frontmost proof does not apply.

Source

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.

Source

pub fn click(&self, x: f64, y: f64, button: &str, count: u32) -> Result<()>

Source

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.

Source

pub fn move_to(&self, x: f64, y: f64) -> Result<()>

Source

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.

Source

pub fn drag(&self, from: (f64, f64), to: (f64, f64), steps: u32) -> Result<()>

Source

pub fn wheel(&self, x: f64, y: f64, dx: f64, dy: f64) -> Result<()>

Source

pub fn key(&self, spec: &str) -> Result<()>

Source

pub fn type_text(&self, text: &str) -> Result<()>

Source

pub fn eval(&self, js: &str) -> Result<Value>

Evaluate a JS function body (return ...) in the page; returns its JSON value.

Source

pub fn dom(&self, selector: &str) -> Result<Vec<Value>>

Source

pub fn ax(&self) -> Result<Vec<Value>>

Source

pub fn screenshot_png(&self) -> Result<Vec<u8>>

Source

pub fn screenshot_to(&self, path: &Path) -> Result<()>

Source

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.

Source

pub fn center_of(&self, selector: &str) -> Result<(f64, f64)>

Centre of the first element matching selector, in viewport CSS px.

Source

pub fn click_selector(&self, selector: &str) -> Result<()>

Source

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.

Source

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.

Source

pub fn log_tail(&self, max_chars: usize) -> String

The last max_chars bytes of the live app log (empty when it is unreadable).

Source

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.

Source

pub fn page_errors(&self) -> Result<Vec<Value>>

Page errors recorded by Control::record_page_errors, oldest first.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Drop for Control

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Eval for Control

Source§

fn eval_js(&self, js: &str) -> Result<Value>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.