page_visit fields and methods A field is a plain fact about the value, read with a dot and no brackets: $value.name. A method takes arguments or does work, and is called with ->: $value->name(arguments), or with the value piped in: $value |> name(arguments).
Fields Field Type Description .htmlstring The page's HTML as it is now, after any clicks. .pathstring The address visited. .statusnumber The HTTP status of the last render. .textstring The words on the page as it is now, without tags and with runs of spaces made one.
From KScript.Web These need <import package="KScript.Web" />import KScript.Web . See KScript.Web .
Runs the on-change handler of the input with this label (the text of the <label> around it), such as a checkbox, and redraws its block.
Parameter Takes text required string
Example
.kscript XML Copy
<let name="page" value="@visit('/settings')->change('Email me updates')" />
<expect value="$page.text" contains="'Saved'" />.kscript XML Copy
$page = @visit('/settings')->change('Email me updates')
expect($page.text, contains: 'Saved')# page_visit ->classes (text: string ) → list KScript.Web The classes of the first element whose own text is this: classes('Buy milk').
Parameter Takes text required string
Example
.kscript XML Copy
<let name="page" value="@visit('/tasks')->click('Buy milk')" />
<expect value="$page->classes('Buy milk')" contains="'done'" />.kscript XML Copy
$page = @visit('/tasks')->click('Buy milk')
expect($page->classes('Buy milk'), contains: 'done')Runs the live on-click handler of the element with this text (or aria-label or title) and redraws its block. Returns the page, so clicks chain.
Parameter Takes text required string
Example
.kscript XML Copy
<let name="page" value="@visit('/counter')->click('Add one')->click('Add one')" />
<expect value="$page.text" contains="'2'" />.kscript XML Copy
$page = @visit('/counter')->click('Add one')->click('Add one')
expect($page.text, contains: '2')Types a value into the input bound to this field (bind="$draft"), sent with the next click or submit.
Parameter Takes field required string value required any value
Arguments can be named: ->fill(…, value: …).
Example
.kscript XML Copy
<let name="page" value="@visit('/tasks')->fill('draft', 'Buy milk')->click('Add')" />
<expect value="$page.text" contains="'Buy milk'" />.kscript XML Copy
$page = @visit('/tasks')->fill('draft', 'Buy milk')->click('Add')
expect($page.text, contains: 'Buy milk')Presses a key on the element with on-keydown (the one with this text, label or placeholder, when given in:): press('enter'), press(['ctrl', 's']).
Parameter Takes key required any value in optional string
Arguments can be named: ->press(…, in: …).
Example
.kscript XML Copy
<let name="page" value="@visit('/tasks')->fill('draft', 'Buy milk')->press('enter', in: 'New task')" />
<expect value="$page.text" contains="'Buy milk'" />.kscript XML Copy
$page = @visit('/tasks')->fill('draft', 'Buy milk')->press('enter', in: 'New task')
expect($page.text, contains: 'Buy milk')Runs the on-submit handler of the form (the one with this text, when given) and redraws its block.
Parameter Takes text optional string
Example
.kscript XML Copy
<let name="page" value="@visit('/signup')->fill('email', 'joan@example.com')->submit('Sign up')" />
<expect value="$page.text" contains="'Check your email'" />.kscript XML Copy
$page = @visit('/signup')->fill('email', 'joan@example.com')->submit('Sign up')
expect($page.text, contains: 'Check your email')Methods from any