Skip to main content

EffectExpectation

Enum EffectExpectation 

Source
pub enum EffectExpectation {
    SelectorAppears {
        selector: String,
        timeout_ms: u64,
    },
    SelectorDisappears {
        selector: String,
        timeout_ms: u64,
    },
    SelectorTextContains {
        selector: String,
        substring: String,
        timeout_ms: u64,
    },
    DomChanged {
        timeout_ms: u64,
    },
}
Expand description

What the runtime should observe after an action lands to confirm the side-effect actually materialised.

Cortex polls the page (via CDP Runtime.evaluate) until the expectation holds or the timeout fires. The result is reported back in the action’s ActionResult so the planner sees not just “dispatched ok” but “dispatched ok AND observed the expected change”.

Closes the “click reported ok but page didn’t react” gap: e.preventDefault() from a validation handler, a remounted DOM node the click landed on but is no longer wired up, an animation that swallowed the click — all previously reported ok and forced the planner to verify state from screenshots after the fact. With expect_after the runtime knows immediately the side-effect didn’t materialise and surfaces an EffectMissing error to the planner.

All variants carry a timeout_ms with a sensible default (2_000 ms) — long enough for animations / debounced handlers, short enough not to add real latency on the happy path (most expectations resolve in one CDP round-trip when the action actually fired).

Variants§

§

SelectorAppears

A new element matching selector becomes visible (offsetParent !== null). Use for “after submit, success message appears”, “after open, modal appears” patterns.

Fields

§selector: String
§timeout_ms: u64
§

SelectorDisappears

An element matching selector becomes invisible (detached or offsetParent === null). Use for “after close, modal disappears”, “after delete, row goes away” patterns.

Fields

§selector: String
§timeout_ms: u64
§

SelectorTextContains

An element matching selector contains the given text. Use for state changes like “button label flips from ‘Approve’ to ‘Approved ✓’”, or “row gains an ‘Approved’ status cell”.

Fields

§selector: String
§substring: String
§timeout_ms: u64
§

DomChanged

The page DOM changed in any meaningful way after the action. Compares a “before” snapshot (captured at dispatch entry) to a “after” snapshot polled until either differs or the timeout fires. The snapshot is small + cheap: visible text length, interactive element count, and current URL.

Use when the post-state isn’t a single named selector but you know the action SHOULD cause SOME visible change — e.g.: • a delete button that removes a row (count decreases), • a tab switch that swaps the entire content panel, • a submit that navigates to a thank-you page (URL changes), • a “load more” that appends results (text length grows).

Strictly weaker than SelectorAppears/Disappears/TextContains — those tell you EXACTLY what should change, this just tells you SOMETHING did. Use the selector-based variants when you have a verbatim selector="..." from perception; fall back to DomChanged when you don’t.

False-positive risk: pages with timestamp tickers / animated counters / live data feeds produce diffs every tick. The 2s default timeout is short enough that most non-action-triggered changes don’t have time to land — but if you’re on a chatty page, prefer a selector-based variant if you can name one.

Fields

§timeout_ms: u64

Trait Implementations§

Source§

impl Clone for EffectExpectation

Source§

fn clone(&self) -> EffectExpectation

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EffectExpectation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for EffectExpectation

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for EffectExpectation

Source§

impl PartialEq for EffectExpectation

Source§

fn eq(&self, other: &EffectExpectation) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for EffectExpectation

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for EffectExpectation

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.