-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
70 lines (59 loc) · 1.85 KB
/
__init__.py
File metadata and controls
70 lines (59 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
Assertion DSL for Sentience SDK.
This module provides a Playwright/Cypress-like assertion API for verifying
browser state in agent verification loops.
Main exports:
- E: Element query builder (filters elements by role, text, href, etc.)
- expect: Expectation builder (creates predicates from queries)
- in_dominant_list: Query over dominant group elements (ordinal access)
Example usage:
from sentience.asserts import E, expect, in_dominant_list
# Basic presence assertions
runtime.assert_(
expect(E(role="button", text_contains="Save")).to_exist(),
label="save_button_visible"
)
# Visibility assertions
runtime.assert_(
expect(E(text_contains="Checkout")).to_be_visible(),
label="checkout_visible"
)
# Global text assertions
runtime.assert_(
expect.text_present("Welcome back"),
label="user_logged_in"
)
runtime.assert_(
expect.no_text("Error"),
label="no_error_message"
)
# Ordinal assertions on dominant group
runtime.assert_(
expect(in_dominant_list().nth(0)).to_have_text_contains("Show HN"),
label="first_item_is_show_hn"
)
# Task completion
runtime.assert_done(
expect.text_present("Order confirmed"),
label="checkout_complete"
)
The DSL compiles to existing Predicate functions, so it works seamlessly
with AgentRuntime.assert_() and assert_done().
"""
from .expect import EventuallyConfig, EventuallyWrapper, ExpectBuilder, expect, with_eventually
from .query import E, ElementQuery, ListQuery, MultiQuery, in_dominant_list
__all__ = [
# Query builders
"E",
"ElementQuery",
"ListQuery",
"MultiQuery",
"in_dominant_list",
# Expectation builders
"expect",
"ExpectBuilder",
# Eventually helpers
"with_eventually",
"EventuallyWrapper",
"EventuallyConfig",
]