common_browser.contracts.targets
Immutable browser queries; a query is distinct from an observed node identity.
Classes
Target
Bases: BaseModel
Describe one element, with explicit nesting, frame and ordinal selection.
Queries may resolve again as a document changes. Use an ElementRef from
a scan when an action must address the exact observed node instead.
Fields and properties declared here; inherited members belong to the bases above.
exact
exact: bool = Trueframe
frame: Target | None = Field(default=None, repr=False)index
index: int | None = Field(default=None, ge=0)kind
kind: Literal['css', 'role', 'label', 'text', 'placeholder', 'test_id', 'title', 'alt']name
name: str | TextPattern | None = Field(default=None, repr=False)value
value: str | TextPattern = Field(repr=False)within
within: Target | None = Field(default=None, repr=False)alt
@classmethoddef alt(text: str | TextPattern | re.Pattern[str], *, exact: bool = True) -> Selfcss
@classmethoddef css(selector: str) -> Selfin_frame
def in_frame(target: Target) -> Selfinside
def inside(target: Target) -> Selflabel
@classmethoddef label(text: str | TextPattern | re.Pattern[str], *, exact: bool = True) -> Selfnth
def nth(index: int) -> Selfplaceholder
@classmethoddef placeholder(text: str | TextPattern | re.Pattern[str], *, exact: bool = True) -> Selfrole
@classmethoddef role(role: str, *, name: str | TextPattern | re.Pattern[str] | None = None, exact: bool = True) -> Selftest_id
@classmethoddef test_id(value: str) -> Selftext
@classmethoddef text(text: str | TextPattern | re.Pattern[str], *, exact: bool = True) -> Selftitle
@classmethoddef title(text: str | TextPattern | re.Pattern[str], *, exact: bool = True) -> SelfTextPattern
Bases: BaseModel
A serialized text regex with explicit flags, using Playwright/JS syntax.
Python compilation catches invalid input, but does not translate Python-only regex constructs into JavaScript. Only the flags supported by Playwright are accepted; the pattern and flags retain separate identities in JSON.
Fields and properties declared here; inherited members belong to the bases above.
flags
flags: int = Field(default=0, ge=0, strict=True)pattern
pattern: str = Field(repr=False)compile
def compile() -> re.Pattern[str]