Page
eval(expression)
Evaluate JS in the Web frontend and return the result. If there’s an error, it will return it like the window usually would (like ReferenceError: notDefined is not defined
).
Arguments
Expression
JS to evaluate, either as a function or string.
Examples
index.js
// Get the current url of the document
const currentUrl = await Window.page.eval(`location.href`);
loaded
A Promise which is resolved when the page loads (like window.onload
).
Examples
index.js
await Window.page.loaded;
// Do stuff which requires page load
reload(ignoreCache = false)
Reload the page, optionally ignoring the cache (for this reload).
Arguments
Ignore cache
Optionally ignore the cache for this reload. Defaults to false.
Examples
index.js
await Window.page.reload(); // Reload the page
await Window.page.reload(true); // Reload the page and ignore the cache
title()
Get the current title of the page.
Examples
index.js
const currentTitle = await Window.page.title();
console.log('Current page title:', currentTitle);
title(newTitle)
Set the title of the page.
Arguments
New title
The new title to set.
Examples
index.js
await Window.page.title('Custom title here');