Page

io.github.frikit.twirlspec.page.Page
See thePage companion object
final class Page(val document: Document, val lang: Lang, val messages: Messages, val source: String, val parseErrors: List[String] = ...)

A rendered page, ready to be asked questions.

The accessors know GOV.UK and HMRC markup, so a page from another design system is still readable through css, byId, byRole and doc.

Value parameters

document

the parsed markup, repaired where the parser had to

lang

the language the page was rendered in

messages

the messages for that language, used to resolve message keys

parseErrors

what the parser had to repair, up to fifty entries

source

the markup as rendered, before any repair

Attributes

Companion
object
Source
Page.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def accessibleDescription(e: Element): String

The description an assistive technology reads after the name.

The description an assistive technology reads after the name.

Attributes

Source
Page.scala
def accessibleName(e: Element): String

The name an assistive technology would announce for an element.

The name an assistive technology would announce for an element.

Attributes

Source
Page.scala

The GOV.UK accordions.

The GOV.UK accordions.

Attributes

Source
Page.scala

The HMRC add-to-a-list components.

The HMRC add-to-a-list components.

Attributes

Source
Page.scala

The GOV.UK bullet lists.

The GOV.UK bullet lists.

Attributes

Source
Page.scala

Every button and submit input.

Every button and submit input.

Attributes

Source
Page.scala
def byId(elementId: String): Selection

The element with this id, matched by attribute rather than CSS syntax, so an id with a dot in it works.

The element with this id, matched by attribute rather than CSS syntax, so an id with a dot in it works.

Attributes

Source
Page.scala
def byRole(role: String): Selection

Elements with this ARIA role, implicit or explicit.

Elements with this ARIA role, implicit or explicit.

Attributes

Source
Page.scala
def byRole(role: String, name: String): Selection

Elements with this role whose accessible name matches.

Elements with this role whose accessible name matches.

Attributes

Source
Page.scala

The GOV.UK caption above a heading, in any of its sizes.

The GOV.UK caption above a heading, in any of its sizes.

Attributes

Source
Page.scala
def checkboxes(fieldName: String): Selection

The checkboxes sharing this name.

The checkboxes sharing this name.

Attributes

Source
Page.scala
def contains(needle: String): Boolean

Whether the page's visible text contains this, after normalisation.

Whether the page's visible text contains this, after normalisation.

Attributes

Source
Page.scala
def coveredAs(name: String): this.type

Count this page's assertions together with those on every other page this spec covers under the same name — the states of one view, say, so that what was asserted on the page with errors counts for the page without:

Count this page's assertions together with those on every other page this spec covers under the same name — the states of one view, say, so that what was asserted on the page with errors counts for the page without:

render(view(form)).coveredAs("name-page")
render(view(formWithErrors)).coveredAs("name-page")

Without it, a page is grouped with the renders that produce exactly its markup. Only a page a spec rendered can share a record; one built directly keeps its own.

Attributes

Source
Page.scala
def css(selector: String): Selection

Every element matching this CSS selector.

Every element matching this CSS selector.

Attributes

Source
Page.scala
def dateInput(fieldName: String): Selection

The fields of a date input, under either id convention.

The fields of a date input, under either id convention.

Attributes

Source
Page.scala

The details components, GOV.UK or plain.

The details components, GOV.UK or plain.

Attributes

Source
Page.scala
def doc: Document

Escape hatch: raw Jsoup.

Escape hatch: raw Jsoup.

Attributes

Source
Page.scala

Every inline error message.

Every inline error message.

Attributes

Source
Page.scala

The GOV.UK error summary.

The GOV.UK error summary.

Attributes

Source
Page.scala

The heading of the error summary.

The heading of the error summary.

Attributes

Source
Page.scala
def fieldErrors: Map[String, String]

Inline error text keyed by the field it belongs to, with the visually hidden "Error:" prefix stripped.

Inline error text keyed by the field it belongs to, with the visually hidden "Error:" prefix stripped.

Attributes

Source
Page.scala

Every fieldset.

Every fieldset.

Attributes

Source
Page.scala
def fileUpload(nameOrId: String): Selection

The file inputs with this name or id.

The file inputs with this name or id.

Attributes

Source
Page.scala
def formAction: Option[String]

The action of the first form, if there is one.

The action of the first form, if there is one.

Attributes

Source
Page.scala
def formControl(nameOrId: String): Selection

Any control by name or id: input, select or textarea.

Any control by name or id: input, select or textarea.

Attributes

Source
Page.scala
def formControls: List[Element]

Every control on the page that a user can type into or choose from.

Every control on the page that a user can type into or choose from.

Attributes

Source
Page.scala
def formMethod: Option[String]

The method of the first form, upper-cased, if there is one.

The method of the first form, upper-cased, if there is one.

Attributes

Source
Page.scala
def formSubmission: Seq[(String, String)]

What the page's forms would submit as their markup stands — before any script runs or anyone types — as name and value pairs in document order.

What the page's forms would submit as their markup stands — before any script runs or anyone types — as name and value pairs in document order.

It is a static reading of the markup, not a submission: every form on the page is read together, and no button is the submitter, so no button's name is included. Within that, it follows the browser. A checkbox counts only when it is checked, and says on when it has no value; of several radios marked checked in one group, only the last is, as checking one unchecks the rest. A select sends its selected options, and a single select with none marked sends the first option that is not disabled, which is what a browser shows as chosen. A textarea sends its text as written, and a file input an empty file name, since markup cannot choose a file. A disabled control sends nothing, and neither do buttons, reset controls or image inputs. A name can appear more than once, as a group of checkboxes does. On a whole page, a control no form owns sends nothing, as in a browser, so a field left outside its form shows; on a fragment every control counts, since its form may be in the template that includes it.

Attributes

Source
Page.scala
def formValues: Map[String, String]

The value each name submits: formSubmission as a map, keeping the last value for a name that is submitted more than once.

The value each name submits: formSubmission as a map, keeping the last value for a name that is submitted more than once.

Attributes

Source
Page.scala

Every form on the page.

Every form on the page.

Attributes

Source
Page.scala
def h1: Selection

The = elements; a page should have exactly one.

The = elements; a page should have exactly one.

Attributes

Source
Page.scala
def headings: List[(Int, String)]

Every heading with its level, in document order.

Every heading with its level, in document order.

Attributes

Source
Page.scala
def hint(fieldId: String): Selection

The hint for this field, by the GOV.UK id convention or inside the field's wrapper.

The hint for this field, by the GOV.UK id convention or inside the field's wrapper.

Attributes

Source
Page.scala

Every GOV.UK hint.

Every GOV.UK hint.

Attributes

Source
Page.scala
def htmlLang: Option[String]

The lang attribute of the `` element, if it has one.

The lang attribute of the `` element, if it has one.

Attributes

Source
Page.scala

Every image.

Every image.

Attributes

Source
Page.scala
def input(nameOrId: String): Selection

The inputs with this name or id.

The inputs with this name or id.

Attributes

Source
Page.scala

The GOV.UK inset text blocks.

The GOV.UK inset text blocks.

Attributes

Source
Page.scala
def isDisabled(e: Element): Boolean

Disabled as a browser sees it: on the control, or inherited from a disabled fieldset — except inside that fieldset's first legend, which HTML leaves enabled so a legend can hold the control that switches the rest on.

Disabled as a browser sees it: on the control, or inherited from a disabled fieldset — except inside that fieldset's first legend, which HTML leaves enabled so a legend can hold the control that switches the rest on.

Attributes

Source
Page.scala
def labelFor(fieldId: String): Selection

The labels pointing at this field.

The labels pointing at this field.

Attributes

Source
Page.scala

A switcher offers another language, so a link declaring the one it is already in does not count — a "report a technical issue" link carrying hreflang="en" on an English page is not a toggle.

A switcher offers another language, so a link declaring the one it is already in does not count — a "report a technical issue" link carrying hreflang="en" on an English page is not a toggle.

Attributes

Source
Page.scala

Every legend.

Every legend.

Attributes

Source
Page.scala

The main content landmark.

The main content landmark.

Attributes

Source
Page.scala
def message(key: String, args: Seq[Any] = ...): Option[String]

Resolve a message key in this page's language. A key the language does not define resolves to nothing, rather than to the English Play would render in its place, so a Welsh assertion cannot pass on English words.

Resolve a message key in this page's language. A key the language does not define resolves to nothing, rather than to the English Play would render in its place, so a Welsh assertion cannot pass on English words.

Attributes

Source
Page.scala
def messageOrKey(key: String, args: Seq[Any] = ...): String

Resolve a key, falling back to the key itself (Play's default behaviour).

Resolve a key, falling back to the key itself (Play's default behaviour).

Attributes

Source
Page.scala
def named(name: String, selector: String): Selection

Every element matching this selector, under a name used in failure messages.

Every element matching this selector, under a name used in failure messages.

Attributes

Source
Page.scala

The GOV.UK notification banners.

The GOV.UK notification banners.

Attributes

Source
Page.scala

The GOV.UK numbered lists.

The GOV.UK numbered lists.

Attributes

Source
Page.scala
def outline: String

Building this touches most of the page, and a failure message is not an assertion, so it must not count as coverage.

Building this touches most of the page, and a failure message is not an assertion, so it must not count as coverage.

Attributes

Source
Page.scala

The GOV.UK or HMRC pagination.

The GOV.UK or HMRC pagination.

Attributes

Source
Page.scala

The GOV.UK panels.

The GOV.UK panels.

Attributes

Source
Page.scala

The paragraphs of body text.

The paragraphs of body text.

Attributes

Source
Page.scala

The alpha or beta phase banner.

The alpha or beta phase banner.

Attributes

Source
Page.scala
def positionOf(e: Element): Int

Position in document order, for asserting one thing comes before another.

Position in document order, for asserting one thing comes before another.

Attributes

Source
Page.scala
def radios(fieldName: String): Selection

The radio buttons sharing this name.

The radio buttons sharing this name.

Attributes

Source
Page.scala
def selectBox(nameOrId: String): Selection

The selects with this name or id.

The selects with this name or id.

Attributes

Source
Page.scala

The service name in a GOV.UK or HMRC header.

The service name in a GOV.UK or HMRC header.

Attributes

Source
Page.scala

The control that submits the form, chosen among those that can submit one: a button whose type is submit, missing or one HTML does not know, a submit input or an image input. The one with the id submit comes first, then those inside a form, then any.

The control that submits the form, chosen among those that can submit one: a button whose type is submit, missing or one HTML does not know, a submit input or an image input. The one with the id submit comes first, then those inside a form, then any.

Attributes

Source
Page.scala

Every GOV.UK summary list.

Every GOV.UK summary list.

Attributes

Source
Page.scala
def summaryRows: List[(String, String, List[String])]

Summary list rows as (key, value, action texts).

Summary list rows as (key, value, action texts).

Attributes

Source
Page.scala

Every table.

Every table.

Attributes

Source
Page.scala

The GOV.UK tabs.

The GOV.UK tabs.

Attributes

Source
Page.scala

The GOV.UK tags.

The GOV.UK tags.

Attributes

Source
Page.scala
def text: String

The page's visible text, normalised: its body, and not the ``, which is shown in a browser's tab rather than on the page.

The page's visible text, normalised: its body, and not the ``, which is shown in a browser's tab rather than on the page.

Attributes

Source
Page.scala
def textarea(nameOrId: String): Selection

The textareas with this name or id.

The textareas with this name or id.

Attributes

Source
Page.scala

The HMRC session timeout dialog.

The HMRC session timeout dialog.

Attributes

Source
Page.scala
def title: String

The browser title, normalised.

The browser title, normalised.

Attributes

Source
Page.scala
override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any
Source
Page.scala

The text of the GOV.UK warning callouts.

The text of the GOV.UK warning callouts.

Attributes

Source
Page.scala
def withLang(newLang: Lang, newMessages: Messages): Page

The same page, read in another language. It is the same page for coverage too: what is asserted on either counts for both.

The same page, read in another language. It is the same page for coverage too: what is asserted on either counts for both.

Attributes

Source
Page.scala

Concrete fields

val document: Document

Attributes

Source
Page.scala
val lang: Lang

Attributes

Source
Page.scala
val messages: Messages

Attributes

Source
Page.scala
val parseErrors: List[String]

Attributes

Source
Page.scala
val source: String

Attributes

Source
Page.scala