class: page
[32:14] (extern: com.lehman.aussom.APage) extends: object
The page class represents a single browser tab. It is the primary surface for all DOM interaction including navigation, content inspection, and element interaction via locators. Instances are obtained by calling browser.newPage() or browsercontext.newPage().
Methods
-
navigate (
string Url)Navigates the page to the given URL.
- @p
Urlis a string with the URL. - @r
Aresponse object for the main resource or null.
- @p
-
goBack ()
Navigates back in the browser history.
- @r
Aresponse object or null if navigation was not possible.
- @r
-
goForward ()
Navigates forward in the browser history.
- @r
Aresponse object or null if navigation was not possible.
- @r
-
reload ()
Reloads the current page.
- @r
Aresponse object for the main resource response.
- @r
-
content ()
Returns the full outer HTML of the page including the doctype.
- @r
Astring with the page HTML content.
- @r
-
setContent (
string Html)Sets the full HTML content of the page.
- @p
Htmlis a string with the HTML to set as the page content. - @r
Thisobject.
- @p
-
title ()
Returns the page title from the document title element.
- @r
Astring with the page title.
- @r
-
url ()
Returns the current URL of the page.
- @r
Astring with the current page URL.
- @r
-
close ()
Closes the page.
- @r
Thisobject.
- @r
-
isClosed ()
Returns whether the page has been closed.
- @r
Abool - true if the page is closed.
- @r
-
bringToFront ()
Brings the page to the foreground (activates the tab).
- @r
Thisobject.
- @r
-
pause ()
Pauses script execution and opens the Playwright Inspector for debugging. Only useful in headed mode.
- @r
Thisobject.
- @r
-
locator (
string Selector)Creates a locator for elements matching the given CSS or XPath selector.
- @p
Selectoris a string CSS or XPath selector. - @r
Alocator object for elements matching the selector.
- @p
-
getByRole (
string Role)Creates a locator for elements matching the given ARIA role.
- @p
Roleis a string ARIA role name (e.g. 'button', 'heading', 'link'). - @r
Alocator object.
- @p
-
getByText (
string Text)Creates a locator for elements by their visible text content.
- @p
Textis a string of visible text to match. - @r
Alocator object.
- @p
-
getByLabel (
string Label)Creates a locator for form inputs by their associated label text.
- @p
Labelis a string label text to match. - @r
Alocator object.
- @p
-
getByPlaceholder (
string Placeholder)Creates a locator for form inputs by their placeholder text.
- @p
Placeholderis a string placeholder text to match. - @r
Alocator object.
- @p
-
getByAltText (
string AltText)Creates a locator for elements by their alt text attribute.
- @p
AltTextis a string alt attribute value to match. - @r
Alocator object.
- @p
-
getByTitle (
string Title)Creates a locator for elements by their title attribute.
- @p
Titleis a string title attribute value to match. - @r
Alocator object.
- @p
-
getByTestId (
string TestId)Creates a locator for elements by their test ID attribute (data-testid by default).
- @p
TestIdis a string test ID value to match. - @r
Alocator object.
- @p
-
evaluate (
string Expression)Evaluates a JavaScript expression in the page context and returns the result. The expression can be a function body string or an arrow function.
- @p
Expressionis a string JavaScript expression to evaluate. - @r
Theserialized result of the expression.
- @p
-
addInitScript (
string Script)Injects a JavaScript script to be executed in every new page load before other scripts run.
- @p
Scriptis a string of JavaScript source code. - @r
Thisobject.
- @p
-
screenshot (
string Path)Captures a screenshot of the visible page area and saves it to disk.
- @p
Pathis a string file path where the screenshot will be saved (PNG or JPEG). - @r
Thisobject.
- @p
-
pdf (
string Path)Renders the page to a PDF and saves it to disk. Chromium only.
- @p
Pathis a string file path where the PDF will be saved. - @r
Thisobject.
- @p
-
setViewportSize (
int Width, int Height)Sets the page viewport size in pixels.
- @p
Widthis an int width in pixels. - @p
Heightis an int height in pixels. - @r
Thisobject.
- @p
-
viewportSize ()
Returns the current viewport size as a map with 'width' and 'height' keys.
- @r
Amap with int keys 'width' and 'height'.
- @r
-
context ()
Returns the browser context that owns this page.
- @r
Abrowsercontext object.
- @r
-
waitForLoadState (
string State)Waits for the page to reach the given load state.
- @p
Stateis a string: 'load', 'domcontentloaded', or 'networkidle'. - @r
Thisobject.
- @p
-
waitForURL (
string Url)Waits for the page URL to match the given URL string.
- @p
Urlis a string URL to wait for. - @r
Thisobject.
- @p
-
waitForTimeout (
double Timeout)Pauses execution for the given number of milliseconds.
- @p
Timeoutis a double number of milliseconds to wait. - @r
Thisobject.
- @p
-
waitForFunction (
string Expression)Waits until a JavaScript expression evaluates to truthy.
- @p
Expressionis a string JavaScript expression to poll. - @r
Thisobject.
- @p
-
keyboard ()
Returns the keyboard sub-object for low-level keyboard input simulation.
- @r
Akeyboard object.
- @r
-
mouse ()
Returns the mouse sub-object for low-level mouse input simulation.
- @r
Amouse object.
- @r
-
waitForDialog ()
Waits for a dialog event (alert, confirm, prompt) and returns the dialog object. The action runnable should trigger the dialog.
- @r
Adialog object.
- @r
-
waitForConsoleMessage ()
Waits for a console message event and returns it.
- @r
Aconsolemessage object.
- @r
-
onConsoleMessage (
callback OnMessage)Registers a streaming console-message handler. The provided callback is invoked once per browser console event (log, info, warn, error, debug, dir, trace) from the moment the listener is installed until the page is closed. Complements waitForConsoleMessage, which waits for a single event. Typical use: capture every console line into a test log to surface browser-side errors (including aussom-script c.err output) in Playwright failures.
- @p
OnMessageis a callback invoked as OnMessage(consolemessage) per event. - @r
Thisobject.
- @p
-
onPageError (
callback OnError)Registers a streaming page-error handler. The callback fires once per uncaught JavaScript exception in the page, which includes aussom-script runtime errors that escape catch blocks. Pair with onConsoleMessage to cover every failure the browser reports.
- @p
OnErroris a callback invoked as OnError(string message). - @r
Thisobject.
- @p
-
waitForRequest (
string Url)Waits for a network request matching the given URL and returns it.
- @p
Urlis a string URL pattern to match. - @r
Arequest object.
- @p
-
waitForResponse (
string Url)Waits for a network response matching the given URL and returns it.
- @p
Urlis a string URL pattern to match. - @r
Aresponse object.
- @p