diff --git a/docs/_includes/version/browsertime.txt b/docs/_includes/version/browsertime.txt index 9003aff9d..348aecd96 100644 --- a/docs/_includes/version/browsertime.txt +++ b/docs/_includes/version/browsertime.txt @@ -1 +1 @@ -21.5.2 \ No newline at end of file +21.5.3 \ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/Actions.html b/docs/documentation/sitespeed.io/scripting/Actions.html index a78800c56..6394dd198 100644 --- a/docs/documentation/sitespeed.io/scripting/Actions.html +++ b/docs/documentation/sitespeed.io/scripting/Actions.html @@ -1,8 +1,8 @@ Class: Actions
On this page

Actions

This class provides an abstraction layer for Selenium's action sequence functionality. It allows for easy interaction with web elements using different locating strategies and simulating complex user gestures like mouse movements, key presses, etc.

Classes

Actions

Methods

getActions() → {SeleniumActions}

Retrieves the current action sequence builder. The actions builder can be used to chain multiple browser actions.
Returns:
The current Selenium Actions builder object for chaining browser actions.
Type: 
SeleniumActions
Example
// Example of using the actions builder to perform a drag-and-drop operation:
+    
On this page

Actions

This class provides an abstraction layer for Selenium's action sequence functionality. It allows for easy interaction with web elements using different locating strategies and simulating complex user gestures like mouse movements, key presses, etc.

Classes

Actions

Methods

getActions() → {SeleniumActions}

Retrieves the current action sequence builder. The actions builder can be used to chain multiple browser actions.
Returns:
The current Selenium Actions builder object for chaining browser actions.
Type: 
SeleniumActions
Example
// Example of using the actions builder to perform a drag-and-drop operation:
 const elementToDrag = await commands.action.getElementByCss('.draggable');
 const dropTarget = await commands.action.getElementByCss('.drop-target');
 await commands.action.getAction()
   .dragAndDrop(elementToDrag, dropTarget)
-  .perform();
\ No newline at end of file + .perform();
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/AddText.html b/docs/documentation/sitespeed.io/scripting/AddText.html index 03d04046f..704c5e86b 100644 --- a/docs/documentation/sitespeed.io/scripting/AddText.html +++ b/docs/documentation/sitespeed.io/scripting/AddText.html @@ -1,3 +1,3 @@ Class: AddText
On this page

AddText

Provides functionality to add text to elements on a web page using various selectors.

Classes

AddText

Methods

(async) byClassName(text, className) → {Promise.<void>}

Adds text to an element identified by its class name.
Parameters:
NameTypeDescription
textstringThe text string to add.
classNamestringThe class name of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the text has been added.
Type: 
Promise.<void>
Example
commands.addText.byClassName('mytext', 'className');

(async) byId(text, id) → {Promise.<void>}

Adds text to an element identified by its ID.
Parameters:
NameTypeDescription
textstringThe text string to add.
idstringThe ID of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the text has been added.
Type: 
Promise.<void>
Example
commands.addText.byId('mytext', 'id');

(async) byName(text, name) → {Promise.<void>}

Adds text to an element identified by its name attribute.
Parameters:
NameTypeDescription
textstringThe text string to add.
namestringThe name attribute of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the text has been added.
Type: 
Promise.<void>
Example
commands.addText.byName('mytext', 'name');

(async) bySelector(text, selector) → {Promise.<void>}

Adds text to an element identified by its CSS selector.
Parameters:
NameTypeDescription
textstringThe text string to add.
selectorstringThe CSS selector of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the text has been added.
Type: 
Promise.<void>
Example
commands.addText.bySelector('mytext', 'selector');

(async) byXpath(text, xpath) → {Promise.<void>}

Adds text to an element identified by its XPath.
Parameters:
NameTypeDescription
textstringThe text string to add.
xpathstringThe XPath of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the text has been added.
Type: 
Promise.<void>
Example
commands.addText.byXpath('mytext', 'xpath');
sitespeed.io scripting
\ No newline at end of file +
On this page

AddText

Provides functionality to add text to elements on a web page using various selectors.

Classes

AddText

Methods

(async) byClassName(text, className) → {Promise.<void>}

Adds text to an element identified by its class name.
Parameters:
NameTypeDescription
textstringThe text string to add.
classNamestringThe class name of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the text has been added.
Type: 
Promise.<void>
Example
commands.addText.byClassName('mytext', 'className');

(async) byId(text, id) → {Promise.<void>}

Adds text to an element identified by its ID.
Parameters:
NameTypeDescription
textstringThe text string to add.
idstringThe ID of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the text has been added.
Type: 
Promise.<void>
Example
commands.addText.byId('mytext', 'id');

(async) byName(text, name) → {Promise.<void>}

Adds text to an element identified by its name attribute.
Parameters:
NameTypeDescription
textstringThe text string to add.
namestringThe name attribute of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the text has been added.
Type: 
Promise.<void>
Example
commands.addText.byName('mytext', 'name');

(async) bySelector(text, selector) → {Promise.<void>}

Adds text to an element identified by its CSS selector.
Parameters:
NameTypeDescription
textstringThe text string to add.
selectorstringThe CSS selector of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the text has been added.
Type: 
Promise.<void>
Example
commands.addText.bySelector('mytext', 'selector');

(async) byXpath(text, xpath) → {Promise.<void>}

Adds text to an element identified by its XPath.
Parameters:
NameTypeDescription
textstringThe text string to add.
xpathstringThe XPath of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the text has been added.
Type: 
Promise.<void>
Example
commands.addText.byXpath('mytext', 'xpath');
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/AndroidCommand.html b/docs/documentation/sitespeed.io/scripting/AndroidCommand.html index 1b7ecc3cf..9179cecb6 100644 --- a/docs/documentation/sitespeed.io/scripting/AndroidCommand.html +++ b/docs/documentation/sitespeed.io/scripting/AndroidCommand.html @@ -1,3 +1,3 @@ Class: AndroidCommand
On this page

AndroidCommand

Provides functionality to interact with an Android device through shell commands.

Classes

AndroidCommand

Methods

(async) shell(command) → {Promise.<string>}

Runs a shell command on the connected Android device. This method requires the Android device to be properly configured.
Parameters:
NameTypeDescription
commandstringThe shell command to run on the Android device.
Throws:
Throws an error if Android is not configured or if the command fails.
Type
Error
Returns:
A promise that resolves with the result of the command or rejects if there's an error.
Type: 
Promise.<string>
Example
await commands.android.shell('');

(async) shellAsRoot(command) → {Promise.<string>}

Runs a shell command on the connected Android device as the root user. This method requires the Android device to be properly configured and that you rooted the device.
Parameters:
NameTypeDescription
commandstringThe shell command to run on the Android device as root.
Throws:
Throws an error if Android is not configured or if the command fails.
Type
Error
Returns:
A promise that resolves with the result of the command or rejects if there's an error.
Type: 
Promise.<string>
Example
await commands.android.shellAsRoot('');
sitespeed.io scripting
\ No newline at end of file +
On this page

AndroidCommand

Provides functionality to interact with an Android device through shell commands.

Classes

AndroidCommand

Methods

(async) shell(command) → {Promise.<string>}

Runs a shell command on the connected Android device. This method requires the Android device to be properly configured.
Parameters:
NameTypeDescription
commandstringThe shell command to run on the Android device.
Throws:
Throws an error if Android is not configured or if the command fails.
Type
Error
Returns:
A promise that resolves with the result of the command or rejects if there's an error.
Type: 
Promise.<string>
Example
await commands.android.shell('');

(async) shellAsRoot(command) → {Promise.<string>}

Runs a shell command on the connected Android device as the root user. This method requires the Android device to be properly configured and that you rooted the device.
Parameters:
NameTypeDescription
commandstringThe shell command to run on the Android device as root.
Throws:
Throws an error if Android is not configured or if the command fails.
Type
Error
Returns:
A promise that resolves with the result of the command or rejects if there's an error.
Type: 
Promise.<string>
Example
await commands.android.shellAsRoot('');
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/Bidi.html b/docs/documentation/sitespeed.io/scripting/Bidi.html index baead1d0a..cfb5fbe90 100644 --- a/docs/documentation/sitespeed.io/scripting/Bidi.html +++ b/docs/documentation/sitespeed.io/scripting/Bidi.html @@ -1,3 +1,14 @@ Class: Bidi
On this page

Bidi

Manages interactions using Bidi. At the moment this only works for Firefox but Chrome and maybe other browsers will support it in the future.

Classes

Bidi

Methods

(async) getRawClient() → {Promise.<Object>}

Retrieves the raw client for Bidi.
Throws:
Throws an error if the browser is not supported.
Type
Error
Returns:
A promise that resolves to the Bidi client.
Type: 
Promise.<Object>
Example
const bidi = await commands.bidi.getRawClient();

(async) onMessage(f)

Add a fanction that will get the events that you subscribes.
Parameters:
NameTypeDescription
ffunctionThe callback function to handle incoming messages. The function will get an event passed on to it. Remember to subscribe to the event.
Throws:
Throws an error if the method is called in a browser other than Firefox.
Type
Error

(async) send(parameters) → {Promise.<Object>}

Sends a command using Bidi.
Parameters:
NameTypeDescription
parametersObjectThe paramaters for the command.
Throws:
Throws an error if the browser is not supported or if the command fails.
Type
Error
Returns:
A promise that resolves when the command has been sent.
Type: 
Promise.<Object>
Example
await commands.bidi.send({});

(async) subscribe(messageType) → {Promise.<Object>}

Subscribe to a event.
Parameters:
NameTypeDescription
messageTypestringThe type of message to subscribe to.
Throws:
Throws an error if the method is called in a browser other than Firefox.
Type
Error
Returns:
A promise that resolves you have subscribed.
Type: 
Promise.<Object>

(async) unsubscribe(messageType) → {Promise.<Object>}

Unsubscribe to an event.
Parameters:
NameTypeDescription
messageTypestringThe type of message to unsubscribe to.
Throws:
Throws an error if the method is called in a browser other than Firefox.
Type
Error
Returns:
A promise that resolves you have unsubscribed.
Type: 
Promise.<Object>
sitespeed.io scripting
\ No newline at end of file +
On this page

Bidi

Manages interactions using Bidi. At the moment this only works for Firefox but Chrome and maybe other browsers will support it in the future.

Classes

Bidi

Methods

getRawClient() → {Promise.<Object>}

Retrieves the raw client for Bidi.
Throws:
Throws an error if the browser is not supported.
Type
Error
Returns:
A promise that resolves to the Bidi client.
Type: 
Promise.<Object>
Example
const bidi = commands.bidi.getRawClient();

(async) onMessage(f)

Add a fanction that will get the events that you subscribes.
Parameters:
NameTypeDescription
ffunctionThe callback function to handle incoming messages. The function will get an event passed on to it. Remember to subscribe to the event.
Throws:
Throws an error if the method is called in a browser other than Firefox.
Type
Error
Example
await commands.bidi.onMessage(function(event) {
+ const myEvent = JSON.parse(Buffer.from(event.toString()));
+ console.log(myEvent);
+});

(async) send(parameters) → {Promise.<Object>}

Sends a command using Bidi.
Parameters:
NameTypeDescription
parametersObjectThe paramaters for the command.
Throws:
Throws an error if the browser is not supported or if the command fails.
Type
Error
Returns:
A promise that resolves when the command has been sent.
Type: 
Promise.<Object>
Example
const params = {
+  method: 'script.addPreloadScript',
+  params: {
+    functionDeclaration: "function() {alert('hello')}"
+   }
+ };
+await commands.bidi.send(params);

(async) subscribe(messageType) → {Promise.<Object>}

Subscribe to a event.
Parameters:
NameTypeDescription
messageTypestringThe type of message to subscribe to.
Throws:
Throws an error if the method is called in a browser other than Firefox.
Type
Error
Returns:
A promise that resolves you have subscribed.
Type: 
Promise.<Object>
Example
// Subscribe to requests before they are sent
+await commands.bidi.subscribe('network.beforeRequestSent');

(async) unsubscribe(messageType) → {Promise.<Object>}

Unsubscribe to an event.
Parameters:
NameTypeDescription
messageTypestringThe type of message to unsubscribe to.
Throws:
Throws an error if the method is called in a browser other than Firefox.
Type
Error
Returns:
A promise that resolves you have unsubscribed.
Type: 
Promise.<Object>
Example
// Unsubscribe to requests before they are sent
+await commands.bidi.unsubscribe('network.beforeRequestSent');
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/Cache.html b/docs/documentation/sitespeed.io/scripting/Cache.html index 516157d77..455147ff3 100644 --- a/docs/documentation/sitespeed.io/scripting/Cache.html +++ b/docs/documentation/sitespeed.io/scripting/Cache.html @@ -1,3 +1,3 @@ Class: Cache
On this page

Cache

Manage the browser cache. This class provides methods to clear the cache and cookies in different browsers.

Classes

Cache

Methods

(async) clear() → {Promise.<void>}

Clears the browser cache. This includes both cache and cookies. For Firefox, it uses the extensionServer setup with specific options. For Chrome and Edge, it uses the Chrome DevTools Protocol (CDP) commands. If the browser is not supported, logs an error message.
Throws:
Will throw an error if the browser is not supported.
Returns:
A promise that resolves when the cache and cookies are cleared.
Type: 
Promise.<void>
Example
await commands.cache.clear();

(async) clearKeepCookies() → {Promise.<void>}

Clears the browser cache while keeping the cookies. For Firefox, it uses the extensionServer setup with specific options. For Chrome and Edge, it uses the Chrome DevTools Protocol (CDP) command to clear the cache. If the browser is not supported, logs an error message.
Throws:
Will throw an error if the browser is not supported.
Returns:
A promise that resolves when the cache is cleared but cookies are kept.
Type: 
Promise.<void>
Example
await commands.cache.clearKeepCookies();
sitespeed.io scripting
\ No newline at end of file +
On this page

Cache

Manage the browser cache. This class provides methods to clear the cache and cookies in different browsers.

Classes

Cache

Methods

(async) clear() → {Promise.<void>}

Clears the browser cache. This includes both cache and cookies. For Firefox, it uses the extensionServer setup with specific options. For Chrome and Edge, it uses the Chrome DevTools Protocol (CDP) commands. If the browser is not supported, logs an error message.
Throws:
Will throw an error if the browser is not supported.
Returns:
A promise that resolves when the cache and cookies are cleared.
Type: 
Promise.<void>
Example
await commands.cache.clear();

(async) clearKeepCookies() → {Promise.<void>}

Clears the browser cache while keeping the cookies. For Firefox, it uses the extensionServer setup with specific options. For Chrome and Edge, it uses the Chrome DevTools Protocol (CDP) command to clear the cache. If the browser is not supported, logs an error message.
Throws:
Will throw an error if the browser is not supported.
Returns:
A promise that resolves when the cache is cleared but cookies are kept.
Type: 
Promise.<void>
Example
await commands.cache.clearKeepCookies();
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/ChromeDevelopmentToolsProtocol.html b/docs/documentation/sitespeed.io/scripting/ChromeDevelopmentToolsProtocol.html index 205469a4b..bd350e668 100644 --- a/docs/documentation/sitespeed.io/scripting/ChromeDevelopmentToolsProtocol.html +++ b/docs/documentation/sitespeed.io/scripting/ChromeDevelopmentToolsProtocol.html @@ -1,3 +1,3 @@ Class: ChromeDevelopmentToolsProtocol
On this page

ChromeDevelopmentToolsProtocol

Manages interactions with the Chrome DevTools Protocol for Chrome and Edge browsers. Allows sending commands and setting up event listeners via the protocol.

Classes

ChromeDevelopmentToolsProtocol

Methods

getRawClient() → {Object}

Retrieves the raw client for the DevTools Protocol.
Throws:
Throws an error if the browser is not supported.
Type
Error
Returns:
The raw DevTools Protocol client.
Type: 
Object
Example
const cdpClient = commands.cdp.getRawClient();

(async) on(event, f)

Sets up an event listener for a specific DevTools Protocol event.
Parameters:
NameTypeDescription
eventstringThe name of the event to listen for.
ffunctionThe callback function to execute when the event is triggered.
Throws:
Throws an error if the browser is not supported or if setting the listener fails.
Type
Error

(async) send(command, arguments_) → {Promise.<void>}

Sends a command to the DevTools Protocol.
Parameters:
NameTypeDescription
commandstringThe DevTools Protocol command to send.
arguments_ObjectThe arguments for the command.
Throws:
Throws an error if the browser is not supported or if the command fails.
Type
Error
Returns:
A promise that resolves when the command has been sent.
Type: 
Promise.<void>
Example
await commands.cdp.send('');

(async) sendAndGet(command, arguments_) → {Promise.<Object>}

Sends a command to the DevTools Protocol and returns the result.
Parameters:
NameTypeDescription
commandstringThe DevTools Protocol command to send.
arguments_ObjectThe arguments for the command.
Throws:
Throws an error if the browser is not supported or if the command fails.
Type
Error
Returns:
The result of the command execution.
Type: 
Promise.<Object>
Example
const domCounters = await commands.cdp.sendAndGet('Memory.getDOMCounters');
sitespeed.io scripting
\ No newline at end of file +
On this page

ChromeDevelopmentToolsProtocol

Manages interactions with the Chrome DevTools Protocol for Chrome and Edge browsers. Allows sending commands and setting up event listeners via the protocol.

Classes

ChromeDevelopmentToolsProtocol

Methods

getRawClient() → {Object}

Retrieves the raw client for the DevTools Protocol.
Throws:
Throws an error if the browser is not supported.
Type
Error
Returns:
The raw DevTools Protocol client.
Type: 
Object
Example
const cdpClient = commands.cdp.getRawClient();

(async) on(event, f)

Sets up an event listener for a specific DevTools Protocol event.
Parameters:
NameTypeDescription
eventstringThe name of the event to listen for.
ffunctionThe callback function to execute when the event is triggered.
Throws:
Throws an error if the browser is not supported or if setting the listener fails.
Type
Error

(async) send(command, arguments_) → {Promise.<void>}

Sends a command to the DevTools Protocol.
Parameters:
NameTypeDescription
commandstringThe DevTools Protocol command to send.
arguments_ObjectThe arguments for the command.
Throws:
Throws an error if the browser is not supported or if the command fails.
Type
Error
Returns:
A promise that resolves when the command has been sent.
Type: 
Promise.<void>
Example
await commands.cdp.send('');

(async) sendAndGet(command, arguments_) → {Promise.<Object>}

Sends a command to the DevTools Protocol and returns the result.
Parameters:
NameTypeDescription
commandstringThe DevTools Protocol command to send.
arguments_ObjectThe arguments for the command.
Throws:
Throws an error if the browser is not supported or if the command fails.
Type
Error
Returns:
The result of the command execution.
Type: 
Promise.<Object>
Example
const domCounters = await commands.cdp.sendAndGet('Memory.getDOMCounters');
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/ChromeTrace.html b/docs/documentation/sitespeed.io/scripting/ChromeTrace.html index e1aec1cff..6d7e0f76b 100644 --- a/docs/documentation/sitespeed.io/scripting/ChromeTrace.html +++ b/docs/documentation/sitespeed.io/scripting/ChromeTrace.html @@ -1,3 +1,3 @@ Class: ChromeTrace
On this page

ChromeTrace

Manages Chrome trace functionality, enabling custom profiling and trace collection in Chrome.

Classes

ChromeTrace

Methods

(async) start() → {Promise.<void>}

Starts the Chrome trace collection.
Throws:
Throws an error if not running Chrome or if configuration is not set for custom tracing.
Type
Error
Returns:
A promise that resolves when tracing is started.
Type: 
Promise.<void>
Example
await commands.trace.start();

(async) stop() → {Promise.<void>}

Stops the Chrome trace collection, processes the collected data, and attaches it to the result object.
Throws:
Throws an error if not running Chrome or if custom tracing was not started.
Type
Error
Returns:
A promise that resolves when tracing is stopped and data is processed.
Type: 
Promise.<void>
Example
await commands.trace.stop();
sitespeed.io scripting
\ No newline at end of file +
On this page

ChromeTrace

Manages Chrome trace functionality, enabling custom profiling and trace collection in Chrome.

Classes

ChromeTrace

Methods

(async) start() → {Promise.<void>}

Starts the Chrome trace collection.
Throws:
Throws an error if not running Chrome or if configuration is not set for custom tracing.
Type
Error
Returns:
A promise that resolves when tracing is started.
Type: 
Promise.<void>
Example
await commands.trace.start();

(async) stop() → {Promise.<void>}

Stops the Chrome trace collection, processes the collected data, and attaches it to the result object.
Throws:
Throws an error if not running Chrome or if custom tracing was not started.
Type
Error
Returns:
A promise that resolves when tracing is stopped and data is processed.
Type: 
Promise.<void>
Example
await commands.trace.stop();
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/Click.html b/docs/documentation/sitespeed.io/scripting/Click.html index a08dbdba4..00392d944 100644 --- a/docs/documentation/sitespeed.io/scripting/Click.html +++ b/docs/documentation/sitespeed.io/scripting/Click.html @@ -1,3 +1,3 @@ Class: Click
On this page

Click

Provides functionality to perform click actions on elements in a web page using various selectors.

Classes

Click

Methods

(async) byClassName(className) → {Promise.<void>}

Clicks on an element identified by its class name.
Parameters:
NameTypeDescription
classNamestringThe class name of the element to click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) byClassNameAndWait(className) → {Promise.<void>}

Clicks on an element identified by its class name and waits for the page complete check to finish.
Parameters:
NameTypeDescription
classNamestringThe class name of the element to click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the click action and page complete check are finished.
Type: 
Promise.<void>

(async) byId(id) → {Promise.<void>}

Clicks on an element located by its ID.
Parameters:
NameTypeDescription
idstringThe ID of the element to click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) byIdAndWait(id) → {Promise.<void>}

Click on link located by the ID attribute. Uses document.getElementById() to find the element. And wait for page complete check to finish.
Parameters:
NameTypeDescription
idstring
Throws:
Will throw an error if the element is not found
Returns:
Promise object represents when the element has been clicked and the pageCompleteCheck has finished.
Type: 
Promise.<void>

(async) byJs(js) → {Promise.<void>}

Clicks on an element located by evaluating a JavaScript expression.
Parameters:
NameTypeDescription
jsstringThe JavaScript expression that evaluates to an element or list of elements.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) byJsAndWait(js) → {Promise.<void>}

Clicks on an element located by evaluating a JavaScript expression and waits for the page complete check to finish.
Parameters:
NameTypeDescription
jsstringThe JavaScript expression that evaluates to an element or list of elements.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the click action and page complete check are finished.
Type: 
Promise.<void>

(async) byLinkText(text) → {Promise.<void>}

Clicks on a link whose visible text matches the given string.
Parameters:
NameTypeDescription
textstringThe visible text of the link to click.
Throws:
Throws an error if the link is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) byLinkTextAndWait(text) → {Promise.<void>}

Clicks on a link whose visible text matches the given string and waits for the page complete check to finish.
Parameters:
NameTypeDescription
textstringThe visible text of the link to click.
Throws:
Throws an error if the link is not found.
Type
Error
Returns:
A promise that resolves when the click action and page complete check are finished.
Type: 
Promise.<void>

(async) byName(name) → {Promise.<void>}

Clicks on an element located by its name attribute.
Parameters:
NameTypeDescription
namestringThe name attribute of the element to click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) byPartialLinkText(text) → {Promise.<void>}

Clicks on a link whose visible text contains the given substring.
Parameters:
NameTypeDescription
textstringThe substring of the visible text of the link to click.
Throws:
Throws an error if the link is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) byPartialLinkTextAndWait(text) → {Promise.<void>}

Clicks on a link whose visible text contains the given substring and waits for the page complete check to finish.
Parameters:
NameTypeDescription
textstringThe substring of the visible text of the link to click.
Throws:
Throws an error if the link is not found.
Type
Error
Returns:
A promise that resolves when the click action and page complete check are finished.
Type: 
Promise.<void>

(async) bySelector(selector) → {Promise.<void>}

Clicks on an element located by its CSS selector.
Parameters:
NameTypeDescription
selectorstringThe CSS selector of the element to click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) bySelectorAndWait(selector) → {Promise.<void>}

Clicks on an element located by its CSS selector and waits for the page complete check to finish.
Parameters:
NameTypeDescription
selectorstringThe CSS selector of the element to click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the click action and page complete check are finished.
Type: 
Promise.<void>

(async) byXpath(xpath) → {Promise.<void>}

Clicks on an element that matches a given XPath selector.
Parameters:
NameTypeDescription
xpathstringThe XPath selector of the element to click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) byXpathAndWait(xpath) → {Promise.<void>}

Clicks on an element that matches a given XPath selector and waits for the page complete check to finish.
Parameters:
NameTypeDescription
xpathstringThe XPath selector of the element to click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the click action and page complete check are finished.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file +
On this page

Click

Provides functionality to perform click actions on elements in a web page using various selectors.

Classes

Click

Methods

(async) byClassName(className) → {Promise.<void>}

Clicks on an element identified by its class name.
Parameters:
NameTypeDescription
classNamestringThe class name of the element to click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) byClassNameAndWait(className) → {Promise.<void>}

Clicks on an element identified by its class name and waits for the page complete check to finish.
Parameters:
NameTypeDescription
classNamestringThe class name of the element to click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the click action and page complete check are finished.
Type: 
Promise.<void>

(async) byId(id) → {Promise.<void>}

Clicks on an element located by its ID.
Parameters:
NameTypeDescription
idstringThe ID of the element to click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) byIdAndWait(id) → {Promise.<void>}

Click on link located by the ID attribute. Uses document.getElementById() to find the element. And wait for page complete check to finish.
Parameters:
NameTypeDescription
idstring
Throws:
Will throw an error if the element is not found
Returns:
Promise object represents when the element has been clicked and the pageCompleteCheck has finished.
Type: 
Promise.<void>

(async) byJs(js) → {Promise.<void>}

Clicks on an element located by evaluating a JavaScript expression.
Parameters:
NameTypeDescription
jsstringThe JavaScript expression that evaluates to an element or list of elements.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) byJsAndWait(js) → {Promise.<void>}

Clicks on an element located by evaluating a JavaScript expression and waits for the page complete check to finish.
Parameters:
NameTypeDescription
jsstringThe JavaScript expression that evaluates to an element or list of elements.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the click action and page complete check are finished.
Type: 
Promise.<void>

(async) byLinkText(text) → {Promise.<void>}

Clicks on a link whose visible text matches the given string.
Parameters:
NameTypeDescription
textstringThe visible text of the link to click.
Throws:
Throws an error if the link is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) byLinkTextAndWait(text) → {Promise.<void>}

Clicks on a link whose visible text matches the given string and waits for the page complete check to finish.
Parameters:
NameTypeDescription
textstringThe visible text of the link to click.
Throws:
Throws an error if the link is not found.
Type
Error
Returns:
A promise that resolves when the click action and page complete check are finished.
Type: 
Promise.<void>

(async) byName(name) → {Promise.<void>}

Clicks on an element located by its name attribute.
Parameters:
NameTypeDescription
namestringThe name attribute of the element to click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) byPartialLinkText(text) → {Promise.<void>}

Clicks on a link whose visible text contains the given substring.
Parameters:
NameTypeDescription
textstringThe substring of the visible text of the link to click.
Throws:
Throws an error if the link is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) byPartialLinkTextAndWait(text) → {Promise.<void>}

Clicks on a link whose visible text contains the given substring and waits for the page complete check to finish.
Parameters:
NameTypeDescription
textstringThe substring of the visible text of the link to click.
Throws:
Throws an error if the link is not found.
Type
Error
Returns:
A promise that resolves when the click action and page complete check are finished.
Type: 
Promise.<void>

(async) bySelector(selector) → {Promise.<void>}

Clicks on an element located by its CSS selector.
Parameters:
NameTypeDescription
selectorstringThe CSS selector of the element to click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) bySelectorAndWait(selector) → {Promise.<void>}

Clicks on an element located by its CSS selector and waits for the page complete check to finish.
Parameters:
NameTypeDescription
selectorstringThe CSS selector of the element to click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the click action and page complete check are finished.
Type: 
Promise.<void>

(async) byXpath(xpath) → {Promise.<void>}

Clicks on an element that matches a given XPath selector.
Parameters:
NameTypeDescription
xpathstringThe XPath selector of the element to click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) byXpathAndWait(xpath) → {Promise.<void>}

Clicks on an element that matches a given XPath selector and waits for the page complete check to finish.
Parameters:
NameTypeDescription
xpathstringThe XPath selector of the element to click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the click action and page complete check are finished.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/ClickAndHold.html b/docs/documentation/sitespeed.io/scripting/ClickAndHold.html index 063bc5302..9a57d1b9d 100644 --- a/docs/documentation/sitespeed.io/scripting/ClickAndHold.html +++ b/docs/documentation/sitespeed.io/scripting/ClickAndHold.html @@ -1,3 +1,3 @@ Class: ClickAndHold
On this page

ClickAndHold

Provides functionality to click and hold elements on a web page using different strategies.

Classes

ClickAndHold

Methods

(async) atCursor() → {Promise.<void>}

Clicks and holds at the current cursor position.
Throws:
Throws an error if the action cannot be performed.
Type
Error
Returns:
A promise that resolves when the action is performed.
Type: 
Promise.<void>

(async) atPosition(xPos, yPos) → {Promise.<void>}

Clicks and holds at the specified screen coordinates.
Parameters:
NameTypeDescription
xPosnumberThe x-coordinate on the screen.
yPosnumberThe y-coordinate on the screen.
Throws:
Throws an error if the action cannot be performed.
Type
Error
Returns:
A promise that resolves when the action is performed.
Type: 
Promise.<void>

(async) bySelector(selector) → {Promise.<void>}

Clicks and holds on an element that matches a given CSS selector.
Parameters:
NameTypeDescription
selectorstringThe CSS selector of the element to interact with.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the action is performed.
Type: 
Promise.<void>

(async) byXpath(xpath) → {Promise.<void>}

Clicks and holds on an element that matches a given XPath selector.
Parameters:
NameTypeDescription
xpathstringThe XPath selector of the element to interact with.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the action is performed.
Type: 
Promise.<void>

(async) releaseAtPosition(xPos, yPos) → {Promise.<void>}

Releases the mouse button at the specified screen coordinates.
Parameters:
NameTypeDescription
xPosnumberThe x-coordinate on the screen.
yPosnumberThe y-coordinate on the screen.
Throws:
Throws an error if the action cannot be performed.
Type
Error
Returns:
A promise that resolves when the action is performed.
Type: 
Promise.<void>

(async) releaseAtSelector(selector) → {Promise.<void>}

Releases the mouse button on an element matching the specified CSS selector.
Parameters:
NameTypeDescription
selectorstringThe CSS selector of the element to release the mouse on.
Throws:
Throws an error if the action cannot be performed.
Type
Error
Returns:
A promise that resolves when the action is performed.
Type: 
Promise.<void>

(async) releaseAtXpath(xpath) → {Promise.<void>}

Releases the mouse button on an element matching the specified XPath.
Parameters:
NameTypeDescription
xpathstringThe XPath selector of the element to release the mouse on.
Throws:
Throws an error if the action cannot be performed.
Type
Error
Returns:
A promise that resolves when the action is performed.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file +
On this page

ClickAndHold

Provides functionality to click and hold elements on a web page using different strategies.

Classes

ClickAndHold

Methods

(async) atCursor() → {Promise.<void>}

Clicks and holds at the current cursor position.
Throws:
Throws an error if the action cannot be performed.
Type
Error
Returns:
A promise that resolves when the action is performed.
Type: 
Promise.<void>

(async) atPosition(xPos, yPos) → {Promise.<void>}

Clicks and holds at the specified screen coordinates.
Parameters:
NameTypeDescription
xPosnumberThe x-coordinate on the screen.
yPosnumberThe y-coordinate on the screen.
Throws:
Throws an error if the action cannot be performed.
Type
Error
Returns:
A promise that resolves when the action is performed.
Type: 
Promise.<void>

(async) bySelector(selector) → {Promise.<void>}

Clicks and holds on an element that matches a given CSS selector.
Parameters:
NameTypeDescription
selectorstringThe CSS selector of the element to interact with.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the action is performed.
Type: 
Promise.<void>

(async) byXpath(xpath) → {Promise.<void>}

Clicks and holds on an element that matches a given XPath selector.
Parameters:
NameTypeDescription
xpathstringThe XPath selector of the element to interact with.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the action is performed.
Type: 
Promise.<void>

(async) releaseAtPosition(xPos, yPos) → {Promise.<void>}

Releases the mouse button at the specified screen coordinates.
Parameters:
NameTypeDescription
xPosnumberThe x-coordinate on the screen.
yPosnumberThe y-coordinate on the screen.
Throws:
Throws an error if the action cannot be performed.
Type
Error
Returns:
A promise that resolves when the action is performed.
Type: 
Promise.<void>

(async) releaseAtSelector(selector) → {Promise.<void>}

Releases the mouse button on an element matching the specified CSS selector.
Parameters:
NameTypeDescription
selectorstringThe CSS selector of the element to release the mouse on.
Throws:
Throws an error if the action cannot be performed.
Type
Error
Returns:
A promise that resolves when the action is performed.
Type: 
Promise.<void>

(async) releaseAtXpath(xpath) → {Promise.<void>}

Releases the mouse button on an element matching the specified XPath.
Parameters:
NameTypeDescription
xpathstringThe XPath selector of the element to release the mouse on.
Throws:
Throws an error if the action cannot be performed.
Type
Error
Returns:
A promise that resolves when the action is performed.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/Commands.html b/docs/documentation/sitespeed.io/scripting/Commands.html index 255498aa5..069525d49 100644 --- a/docs/documentation/sitespeed.io/scripting/Commands.html +++ b/docs/documentation/sitespeed.io/scripting/Commands.html @@ -1,3 +1,3 @@ Class: Commands
On this page

Commands

Represents the set of commands available in a Browsertime script.

Classes

Commands

Members

action :Actions

Selenium's action sequence functionality.
Type:

addText :AddText

Provides functionality to add text to elements on a web page using various selectors.
Type:

android :AndroidCommand

Provides commands for interacting with an Android device.

bidi :Bidi

Use WebDriver Bidi. Availible in Firefox and in the future more browsers.
Type:

cache :Cache

Manages the browser's cache.
Type:

cdp :ChromeDevelopmentToolsProtocol

Use the Chrome DevTools Protocol, available in Chrome and Edge.

click :Click

Provides functionality to perform click actions on elements in a web page using various selectors.
Type:

debug :Debug

Provides debugging capabilities within a browser automation script. It allows setting breakpoints to pause script execution and inspect the current state.
Type:

element :Element

Get Selenium's WebElements.
Type:

error :function

Add a text that will be an error attached to the current page.
Type:
  • function
Example
await commands.error('My error message');

js :JavaScript

Executes JavaScript in the browser context.

markAsFailure :function

Mark this run as an failure. Add a message that explains the failure.
Type:
  • function
Example
await commands.markAsFailure('My failure message');

measure :Measure

Provides functionality for measuring a navigation.
Type:

meta :Meta

Adds metadata to the user journey.
Type:

mouse :Object

Interact with the page using the mouse.
Type:
  • Object
Navigates to a specified URL and handles additional setup for a page visit.
Type:
  • function
Example
await commands.navigate('https://www.example.org');
Provides functionality to control browser navigation such as back, forward, and refresh actions.

screenshot :Screenshot

Takes and manages screenshots.

scroll :Scroll

Provides functionality to control page scrolling in the browser.
Type:

select :Select

Interact with a select element.
Type:

set :Set

Sets values on HTML elements in the page.
Type:

stopWatch :StopWatch

Stopwatch utility for measuring time intervals.

switch :Switch

Switches context to different frames, windows, or tabs in the browser.
Type:

trace :ChromeTrace

Manages Chrome trace functionality, enabling custom profiling and trace collection in Chrome.

wait :Wait

Provides functionality to wait for different conditions in the browser.
Type:
sitespeed.io scripting
\ No newline at end of file +
On this page

Commands

Represents the set of commands available in a Browsertime script.

Classes

Commands

Members

action :Actions

Selenium's action sequence functionality.
Type:

addText :AddText

Provides functionality to add text to elements on a web page using various selectors.
Type:

android :AndroidCommand

Provides commands for interacting with an Android device.

bidi :Bidi

Use WebDriver Bidi. Availible in Firefox and in the future more browsers.
Type:

cache :Cache

Manages the browser's cache.
Type:

cdp :ChromeDevelopmentToolsProtocol

Use the Chrome DevTools Protocol, available in Chrome and Edge.

click :Click

Provides functionality to perform click actions on elements in a web page using various selectors.
Type:

debug :Debug

Provides debugging capabilities within a browser automation script. It allows setting breakpoints to pause script execution and inspect the current state.
Type:

element :Element

Get Selenium's WebElements.
Type:

error :function

Add a text that will be an error attached to the current page.
Type:
  • function
Example
await commands.error('My error message');

js :JavaScript

Executes JavaScript in the browser context.

markAsFailure :function

Mark this run as an failure. Add a message that explains the failure.
Type:
  • function
Example
await commands.markAsFailure('My failure message');

measure :Measure

Provides functionality for measuring a navigation.
Type:

meta :Meta

Adds metadata to the user journey.
Type:

mouse :Object

Interact with the page using the mouse.
Type:
  • Object
Navigates to a specified URL and handles additional setup for a page visit.
Type:
  • function
Example
await commands.navigate('https://www.example.org');
Provides functionality to control browser navigation such as back, forward, and refresh actions.

screenshot :Screenshot

Takes and manages screenshots.

scroll :Scroll

Provides functionality to control page scrolling in the browser.
Type:

select :Select

Interact with a select element.
Type:

set :Set

Sets values on HTML elements in the page.
Type:

stopWatch :StopWatch

Stopwatch utility for measuring time intervals.

switch :Switch

Switches context to different frames, windows, or tabs in the browser.
Type:

trace :ChromeTrace

Manages Chrome trace functionality, enabling custom profiling and trace collection in Chrome.

wait :Wait

Provides functionality to wait for different conditions in the browser.
Type:
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/ContextClick.html b/docs/documentation/sitespeed.io/scripting/ContextClick.html index 1b0262496..46a48e8cd 100644 --- a/docs/documentation/sitespeed.io/scripting/ContextClick.html +++ b/docs/documentation/sitespeed.io/scripting/ContextClick.html @@ -1,3 +1,3 @@ Class: ContextClick
On this page

ContextClick

Provides functionality to perform a context click (right-click) on elements in a web page.

Classes

ContextClick

Methods

(async) atCursor() → {Promise.<void>}

Performs a context click (right-click) at the current cursor position.
Throws:
Throws an error if the context click action cannot be performed.
Type
Error
Returns:
A promise that resolves when the context click action is performed.
Type: 
Promise.<void>

(async) bySelector(selector) → {Promise.<void>}

Performs a context click (right-click) on an element that matches a given CSS selector.
Parameters:
NameTypeDescription
selectorstringThe CSS selector of the element to context click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the context click action is performed.
Type: 
Promise.<void>

(async) byXpath(xpath) → {Promise.<void>}

Performs a context click (right-click) on an element that matches a given XPath selector.
Parameters:
NameTypeDescription
xpathstringThe XPath selector of the element to context click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the context click action is performed.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file +
On this page

ContextClick

Provides functionality to perform a context click (right-click) on elements in a web page.

Classes

ContextClick

Methods

(async) atCursor() → {Promise.<void>}

Performs a context click (right-click) at the current cursor position.
Throws:
Throws an error if the context click action cannot be performed.
Type
Error
Returns:
A promise that resolves when the context click action is performed.
Type: 
Promise.<void>

(async) bySelector(selector) → {Promise.<void>}

Performs a context click (right-click) on an element that matches a given CSS selector.
Parameters:
NameTypeDescription
selectorstringThe CSS selector of the element to context click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the context click action is performed.
Type: 
Promise.<void>

(async) byXpath(xpath) → {Promise.<void>}

Performs a context click (right-click) on an element that matches a given XPath selector.
Parameters:
NameTypeDescription
xpathstringThe XPath selector of the element to context click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the context click action is performed.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/Debug.html b/docs/documentation/sitespeed.io/scripting/Debug.html index 36a140d97..5113c99df 100644 --- a/docs/documentation/sitespeed.io/scripting/Debug.html +++ b/docs/documentation/sitespeed.io/scripting/Debug.html @@ -1,3 +1,3 @@ Class: Debug
On this page

Debug

Provides debugging capabilities within a browser automation script. It allows setting breakpoints to pause script execution and inspect the current state.

Classes

Debug

Methods

(async) breakpoint(nameopt) → {Promise.<void>}

Adds a breakpoint to the script. The browser will pause at the breakpoint, waiting for user input to continue. This is useful for debugging and inspecting the browser state at a specific point in the script.
Parameters:
NameTypeAttributesDescription
namestring<optional>
An optional name for the breakpoint for logging purposes.
Returns:
A promise that resolves when the user chooses to continue from the breakpoint.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file +
On this page

Debug

Provides debugging capabilities within a browser automation script. It allows setting breakpoints to pause script execution and inspect the current state.

Classes

Debug

Methods

(async) breakpoint(nameopt) → {Promise.<void>}

Adds a breakpoint to the script. The browser will pause at the breakpoint, waiting for user input to continue. This is useful for debugging and inspecting the browser state at a specific point in the script.
Parameters:
NameTypeAttributesDescription
namestring<optional>
An optional name for the breakpoint for logging purposes.
Returns:
A promise that resolves when the user chooses to continue from the breakpoint.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/DoubleClick.html b/docs/documentation/sitespeed.io/scripting/DoubleClick.html index 6b9f7bb3f..d6d024145 100644 --- a/docs/documentation/sitespeed.io/scripting/DoubleClick.html +++ b/docs/documentation/sitespeed.io/scripting/DoubleClick.html @@ -1,3 +1,3 @@ Class: DoubleClick
On this page

DoubleClick

Provides functionality to perform a double-click action on elements in a web page.

Classes

DoubleClick

Methods

(async) atCursor(optionsopt) → {Promise.<void>}

Performs a mouse double-click at the current cursor position.
Parameters:
NameTypeAttributesDescription
optionsObject<optional>
Additional options for the double-click action.
Throws:
Throws an error if the double-click action cannot be performed.
Type
Error
Returns:
A promise that resolves when the double-click occurs.
Type: 
Promise.<void>

(async) bySelector(selector, optionsopt) → {Promise.<void>}

Performs a mouse double-click on an element matching a given CSS selector.
Parameters:
NameTypeAttributesDescription
selectorstringThe CSS selector of the element to double-click.
optionsObject<optional>
Additional options for the double-click action.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the double-click action is performed.
Type: 
Promise.<void>

(async) byXpath(xpath, optionsopt) → {Promise.<void>}

Performs a mouse double-click on an element matching a given XPath selector.
Parameters:
NameTypeAttributesDescription
xpathstringThe XPath selector of the element to double-click.
optionsObject<optional>
Additional options for the double-click action.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the double-click action is performed.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file +
On this page

DoubleClick

Provides functionality to perform a double-click action on elements in a web page.

Classes

DoubleClick

Methods

(async) atCursor(optionsopt) → {Promise.<void>}

Performs a mouse double-click at the current cursor position.
Parameters:
NameTypeAttributesDescription
optionsObject<optional>
Additional options for the double-click action.
Throws:
Throws an error if the double-click action cannot be performed.
Type
Error
Returns:
A promise that resolves when the double-click occurs.
Type: 
Promise.<void>

(async) bySelector(selector, optionsopt) → {Promise.<void>}

Performs a mouse double-click on an element matching a given CSS selector.
Parameters:
NameTypeAttributesDescription
selectorstringThe CSS selector of the element to double-click.
optionsObject<optional>
Additional options for the double-click action.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the double-click action is performed.
Type: 
Promise.<void>

(async) byXpath(xpath, optionsopt) → {Promise.<void>}

Performs a mouse double-click on an element matching a given XPath selector.
Parameters:
NameTypeAttributesDescription
xpathstringThe XPath selector of the element to double-click.
optionsObject<optional>
Additional options for the double-click action.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the double-click action is performed.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/Element.html b/docs/documentation/sitespeed.io/scripting/Element.html index 5de1ca1c0..6a920f35a 100644 --- a/docs/documentation/sitespeed.io/scripting/Element.html +++ b/docs/documentation/sitespeed.io/scripting/Element.html @@ -1,3 +1,3 @@ Class: Element
On this page

Element

This class provides a way to get hokld of Seleniums WebElements.

Classes

Element

Methods

(async) getByClassName(className) → {Promise.<WebElement>}

Finds an element by its class name.
Parameters:
NameTypeDescription
classNamestringThe class name of the element.
Returns:
A promise that resolves to the WebElement found.
Type: 
Promise.<WebElement>

(async) getByCss(name) → {Promise.<WebElement>}

Finds an element by its CSS selector.
Parameters:
NameTypeDescription
namestringThe CSS selector of the element.
Returns:
A promise that resolves to the WebElement found.
Type: 
Promise.<WebElement>

(async) getById(id) → {Promise.<WebElement>}

Finds an element by its ID.
Parameters:
NameTypeDescription
idstringThe ID of the element.
Returns:
A promise that resolves to the WebElement found.
Type: 
Promise.<WebElement>

(async) getByName(name) → {Promise.<WebElement>}

Finds an element by its name attribute.
Parameters:
NameTypeDescription
namestringThe name attribute of the element.
Returns:
A promise that resolves to the WebElement found.
Type: 
Promise.<WebElement>

(async) getByXpath(xpath) → {Promise.<WebElement>}

Finds an element by its XPath.
Parameters:
NameTypeDescription
xpathstringThe XPath query of the element.
Returns:
A promise that resolves to the WebElement found.
Type: 
Promise.<WebElement>
sitespeed.io scripting
\ No newline at end of file +
On this page

Element

This class provides a way to get hokld of Seleniums WebElements.

Classes

Element

Methods

(async) getByClassName(className) → {Promise.<WebElement>}

Finds an element by its class name.
Parameters:
NameTypeDescription
classNamestringThe class name of the element.
Returns:
A promise that resolves to the WebElement found.
Type: 
Promise.<WebElement>

(async) getByCss(name) → {Promise.<WebElement>}

Finds an element by its CSS selector.
Parameters:
NameTypeDescription
namestringThe CSS selector of the element.
Returns:
A promise that resolves to the WebElement found.
Type: 
Promise.<WebElement>

(async) getById(id) → {Promise.<WebElement>}

Finds an element by its ID.
Parameters:
NameTypeDescription
idstringThe ID of the element.
Returns:
A promise that resolves to the WebElement found.
Type: 
Promise.<WebElement>

(async) getByName(name) → {Promise.<WebElement>}

Finds an element by its name attribute.
Parameters:
NameTypeDescription
namestringThe name attribute of the element.
Returns:
A promise that resolves to the WebElement found.
Type: 
Promise.<WebElement>

(async) getByXpath(xpath) → {Promise.<WebElement>}

Finds an element by its XPath.
Parameters:
NameTypeDescription
xpathstringThe XPath query of the element.
Returns:
A promise that resolves to the WebElement found.
Type: 
Promise.<WebElement>
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/GeckoProfiler.html b/docs/documentation/sitespeed.io/scripting/GeckoProfiler.html index 0b046887e..2ce64972c 100644 --- a/docs/documentation/sitespeed.io/scripting/GeckoProfiler.html +++ b/docs/documentation/sitespeed.io/scripting/GeckoProfiler.html @@ -1,3 +1,3 @@ Class: GeckoProfiler
On this page

GeckoProfiler

Manages the Gecko Profiler for profiling Firefox performance.

Classes

GeckoProfiler

Methods

(async) start() → {Promise.<void>}

Starts the Gecko Profiler.
Throws:
Throws an error if not running Firefox or if the configuration is not set for custom profiling.
Type
Error
Returns:
A promise that resolves when the profiler is started.
Type: 
Promise.<void>

(async) stop() → {Promise.<void>}

Stops the Gecko Profiler and processes the collected data.
Throws:
Throws an error if not running Firefox or if custom profiling was not started.
Type
Error
Returns:
A promise that resolves when the profiler is stopped and the data is processed.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file +
On this page

GeckoProfiler

Manages the Gecko Profiler for profiling Firefox performance.

Classes

GeckoProfiler

Methods

(async) start() → {Promise.<void>}

Starts the Gecko Profiler.
Throws:
Throws an error if not running Firefox or if the configuration is not set for custom profiling.
Type
Error
Returns:
A promise that resolves when the profiler is started.
Type: 
Promise.<void>

(async) stop() → {Promise.<void>}

Stops the Gecko Profiler and processes the collected data.
Throws:
Throws an error if not running Firefox or if custom profiling was not started.
Type
Error
Returns:
A promise that resolves when the profiler is stopped and the data is processed.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/JavaScript.html b/docs/documentation/sitespeed.io/scripting/JavaScript.html index c993af186..1d13fd019 100644 --- a/docs/documentation/sitespeed.io/scripting/JavaScript.html +++ b/docs/documentation/sitespeed.io/scripting/JavaScript.html @@ -1,3 +1,3 @@ Class: JavaScript
On this page

JavaScript

Provides functionality to execute JavaScript code in the context of the current page.

Classes

JavaScript

Methods

(async) run(js) → {Promise.<*>}

Executes a JavaScript script.
Parameters:
NameTypeDescription
jsstringThe JavaScript code to execute.
Throws:
Throws an error if the JavaScript cannot be executed.
Type
Error
Returns:
A promise that resolves with the result of the executed script.
Type: 
Promise.<*>

(async) runAndWait(js) → {Promise.<*>}

Executes a JavaScript script and waits for the page complete check to finish.
Parameters:
NameTypeDescription
jsstringThe JavaScript code to execute.
Throws:
Throws an error if the JavaScript cannot be executed.
Type
Error
Returns:
A promise that resolves with the result of the executed script and the completion of the page load.
Type: 
Promise.<*>

(async) runPrivileged(js) → {Promise.<*>}

Executes synchronous privileged JavaScript.
Parameters:
NameTypeDescription
jsstringThe privileged JavaScript code to execute.
Throws:
Throws an error if the privileged JavaScript cannot be executed.
Type
Error
Returns:
A promise that resolves with the result of the executed privileged script.
Type: 
Promise.<*>

(async) runPrivilegedAndWait(js) → {Promise.<*>}

Executes synchronous privileged JavaScript and waits for the page complete check to finish.
Parameters:
NameTypeDescription
jsstringThe privileged JavaScript code to execute.
Throws:
Throws an error if the privileged JavaScript cannot be executed.
Type
Error
Returns:
A promise that resolves with the result of the executed privileged script and the completion of the page load.
Type: 
Promise.<*>

(async) runPrivilegedAsync(js) → {Promise.<*>}

Executes asynchronous privileged JavaScript.
Parameters:
NameTypeDescription
jsstringThe asynchronous privileged JavaScript code to execute.
Throws:
Throws an error if the asynchronous privileged JavaScript cannot be executed.
Type
Error
Returns:
A promise that resolves with the result of the executed asynchronous privileged script.
Type: 
Promise.<*>
sitespeed.io scripting
\ No newline at end of file +
On this page

JavaScript

Provides functionality to execute JavaScript code in the context of the current page.

Classes

JavaScript

Methods

(async) run(js) → {Promise.<*>}

Executes a JavaScript script.
Parameters:
NameTypeDescription
jsstringThe JavaScript code to execute.
Throws:
Throws an error if the JavaScript cannot be executed.
Type
Error
Returns:
A promise that resolves with the result of the executed script.
Type: 
Promise.<*>

(async) runAndWait(js) → {Promise.<*>}

Executes a JavaScript script and waits for the page complete check to finish.
Parameters:
NameTypeDescription
jsstringThe JavaScript code to execute.
Throws:
Throws an error if the JavaScript cannot be executed.
Type
Error
Returns:
A promise that resolves with the result of the executed script and the completion of the page load.
Type: 
Promise.<*>

(async) runPrivileged(js) → {Promise.<*>}

Executes synchronous privileged JavaScript.
Parameters:
NameTypeDescription
jsstringThe privileged JavaScript code to execute.
Throws:
Throws an error if the privileged JavaScript cannot be executed.
Type
Error
Returns:
A promise that resolves with the result of the executed privileged script.
Type: 
Promise.<*>

(async) runPrivilegedAndWait(js) → {Promise.<*>}

Executes synchronous privileged JavaScript and waits for the page complete check to finish.
Parameters:
NameTypeDescription
jsstringThe privileged JavaScript code to execute.
Throws:
Throws an error if the privileged JavaScript cannot be executed.
Type
Error
Returns:
A promise that resolves with the result of the executed privileged script and the completion of the page load.
Type: 
Promise.<*>

(async) runPrivilegedAsync(js) → {Promise.<*>}

Executes asynchronous privileged JavaScript.
Parameters:
NameTypeDescription
jsstringThe asynchronous privileged JavaScript code to execute.
Throws:
Throws an error if the asynchronous privileged JavaScript cannot be executed.
Type
Error
Returns:
A promise that resolves with the result of the executed asynchronous privileged script.
Type: 
Promise.<*>
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/Measure.html b/docs/documentation/sitespeed.io/scripting/Measure.html index 78ae8c9b7..d6813b2e4 100644 --- a/docs/documentation/sitespeed.io/scripting/Measure.html +++ b/docs/documentation/sitespeed.io/scripting/Measure.html @@ -1,8 +1,8 @@ Class: Measure
On this page

Measure

A measurement tool for browser-based metrics, handling various aspects of metric collection including navigation, video recording, and data collection.

Classes

Measure

Methods

add(name, value)

Adds a custom metric to the current measurement result. This method should be called after a measurement has started and before it has stopped.
Parameters:
NameTypeDescription
namestringThe name of the metric.
value*The value of the metric.
Throws:
Throws an error if called before a measurement cycle has started.
Type
Error

addObject(object)

Adds multiple custom metrics to the current measurement result. This method accepts an object containing multiple key-value pairs representing different metrics. Similar to `add`, it should be used within an active measurement cycle.
Parameters:
NameTypeDescription
objectObjectAn object containing key-value pairs of metrics to add.
Throws:
Throws an error if called before a measurement cycle has started.
Type
Error

(async) start(urlOrAlias, optionalAliasopt) → {Promise.<void>}

Starts the measurement process for a given URL or an alias. It supports starting measurements by either directly providing a URL or using an alias. If a URL is provided, it navigates to that URL and performs the measurement. If an alias is provided, or no URL is available, it sets up the environment for a user-driven navigation.
Parameters:
NameTypeAttributesDescription
urlOrAliasstringThe URL to navigate to, or an alias representing the test.
optionalAliasstring<optional>
An optional alias that can be used if the first parameter is a URL.
Throws:
Throws an error if navigation fails or if there are issues in the setup process.
Type
Error
Returns:
A promise that resolves when the start process is complete, or rejects if there are errors.
Type: 
Promise.<void>
Example
await commands.measure.start('https://www.example.org');
+    
On this page

Measure

A measurement tool for browser-based metrics, handling various aspects of metric collection including navigation, video recording, and data collection.

Classes

Measure

Methods

add(name, value)

Adds a custom metric to the current measurement result. This method should be called after a measurement has started and before it has stopped.
Parameters:
NameTypeDescription
namestringThe name of the metric.
value*The value of the metric.
Throws:
Throws an error if called before a measurement cycle has started.
Type
Error

addObject(object)

Adds multiple custom metrics to the current measurement result. This method accepts an object containing multiple key-value pairs representing different metrics. Similar to `add`, it should be used within an active measurement cycle.
Parameters:
NameTypeDescription
objectObjectAn object containing key-value pairs of metrics to add.
Throws:
Throws an error if called before a measurement cycle has started.
Type
Error

(async) start(urlOrAlias, optionalAliasopt) → {Promise.<void>}

Starts the measurement process for a given URL or an alias. It supports starting measurements by either directly providing a URL or using an alias. If a URL is provided, it navigates to that URL and performs the measurement. If an alias is provided, or no URL is available, it sets up the environment for a user-driven navigation.
Parameters:
NameTypeAttributesDescription
urlOrAliasstringThe URL to navigate to, or an alias representing the test.
optionalAliasstring<optional>
An optional alias that can be used if the first parameter is a URL.
Throws:
Throws an error if navigation fails or if there are issues in the setup process.
Type
Error
Returns:
A promise that resolves when the start process is complete, or rejects if there are errors.
Type: 
Promise.<void>
Example
await commands.measure.start('https://www.example.org');
 // Or start the measurement and click on a link
 await commands.measure.start();
 await commands.click.byLinkTextAndWait('Documentation');
 // Remember to stop the measurements if you do not provide a URL
-await commands.measure.stop();

(async) stop(testedStartUrl) → {Promise}

Stops the measurement process, collects metrics, and handles any post-measurement tasks. It finalizes the URL being tested, manages any URL-specific metadata, stops any ongoing video recordings, and initiates the data collection process.
Parameters:
NameTypeDescription
testedStartUrlstringThe URL that was initially tested. If not provided, it will be obtained from the browser.
Throws:
Throws an error if there are issues in stopping the measurement or collecting data.
Type
Error
Returns:
A promise that resolves with the collected metrics data.
Type: 
Promise

(async) stopAsError(errorMessage, optionalURL) → {Promise}

Stop the current measurement and mark it as a failure. This stop function will not measure anything on a page. This is useful if you need to stop a measurement in a (try) catch and you know something has failed.
Parameters:
NameTypeDescription
errorMessagestringThe message about the error. This will end up on the HTML report for sitespeed.io so give it a good message so you know what's gone wrong.
optionalURLstringThe URL of the page that you wanted to test. If you don't know the URL (you clicked on a link etc) skip it.
Since
  • 21.2.0
Returns:
A promise that resolves when the stop process has completed.
Type: 
Promise
\ No newline at end of file +await commands.measure.stop();

(async) stop(testedStartUrl) → {Promise}

Stops the measurement process, collects metrics, and handles any post-measurement tasks. It finalizes the URL being tested, manages any URL-specific metadata, stops any ongoing video recordings, and initiates the data collection process.
Parameters:
NameTypeDescription
testedStartUrlstringThe URL that was initially tested. If not provided, it will be obtained from the browser.
Throws:
Throws an error if there are issues in stopping the measurement or collecting data.
Type
Error
Returns:
A promise that resolves with the collected metrics data.
Type: 
Promise

(async) stopAsError(errorMessage, optionalURL) → {Promise}

Stop the current measurement and mark it as a failure. This stop function will not measure anything on a page. This is useful if you need to stop a measurement in a (try) catch and you know something has failed.
Parameters:
NameTypeDescription
errorMessagestringThe message about the error. This will end up on the HTML report for sitespeed.io so give it a good message so you know what's gone wrong.
optionalURLstringThe URL of the page that you wanted to test. If you don't know the URL (you clicked on a link etc) skip it.
Since
  • 21.2.0
Returns:
A promise that resolves when the stop process has completed.
Type: 
Promise
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/Meta.html b/docs/documentation/sitespeed.io/scripting/Meta.html index 4ac6bf04d..308788e3c 100644 --- a/docs/documentation/sitespeed.io/scripting/Meta.html +++ b/docs/documentation/sitespeed.io/scripting/Meta.html @@ -1,3 +1,3 @@ Class: Meta
On this page

Meta

Add meta data to your user journey.

Classes

Meta

Methods

setDescription(text)

Sets the description for the user journey.
Parameters:
NameTypeDescription
textstringThe text to set as the description.
Example
commands.meta.setDescription('My test');

setTitle(text)

Sets the title for the user journey.
Parameters:
NameTypeDescription
textstringThe text to set as the title.
Example
commands.meta.setTitle('Test title');
sitespeed.io scripting
\ No newline at end of file +
On this page

Meta

Add meta data to your user journey.

Classes

Meta

Methods

setDescription(text)

Sets the description for the user journey.
Parameters:
NameTypeDescription
textstringThe text to set as the description.
Example
commands.meta.setDescription('My test');

setTitle(text)

Sets the title for the user journey.
Parameters:
NameTypeDescription
textstringThe text to set as the title.
Example
commands.meta.setTitle('Test title');
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/MouseMove.html b/docs/documentation/sitespeed.io/scripting/MouseMove.html index 9fa911a3a..b42569e76 100644 --- a/docs/documentation/sitespeed.io/scripting/MouseMove.html +++ b/docs/documentation/sitespeed.io/scripting/MouseMove.html @@ -1,3 +1,3 @@ Class: MouseMove
On this page

MouseMove

Provides functionality to move the mouse cursor to elements or specific positions on a web page.

Classes

MouseMove

Methods

(async) byOffset(xOffset, yOffset) → {Promise.<void>}

Moves the mouse cursor by an offset from its current position.
Parameters:
NameTypeDescription
xOffsetnumberThe x offset to move by.
yOffsetnumberThe y offset to move by.
Throws:
Throws an error if the action cannot be performed.
Type
Error
Returns:
A promise that resolves when the mouse has moved by the specified offset.
Type: 
Promise.<void>

(async) bySelector(selector) → {Promise.<void>}

Moves the mouse cursor to an element that matches a given CSS selector.
Parameters:
NameTypeDescription
selectorstringThe CSS selector of the element to move to.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the mouse has moved to the element.
Type: 
Promise.<void>

(async) byXpath(xpath) → {Promise.<void>}

Moves the mouse cursor to an element that matches a given XPath selector.
Parameters:
NameTypeDescription
xpathstringThe XPath selector of the element to move to.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the mouse has moved to the element.
Type: 
Promise.<void>

(async) toPosition(xPos, yPos) → {Promise.<void>}

Moves the mouse cursor to a specific position on the screen.
Parameters:
NameTypeDescription
xPosnumberThe x-coordinate on the screen to move to.
yPosnumberThe y-coordinate on the screen to move to.
Throws:
Throws an error if the action cannot be performed.
Type
Error
Returns:
A promise that resolves when the mouse has moved to the specified position.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file +
On this page

MouseMove

Provides functionality to move the mouse cursor to elements or specific positions on a web page.

Classes

MouseMove

Methods

(async) byOffset(xOffset, yOffset) → {Promise.<void>}

Moves the mouse cursor by an offset from its current position.
Parameters:
NameTypeDescription
xOffsetnumberThe x offset to move by.
yOffsetnumberThe y offset to move by.
Throws:
Throws an error if the action cannot be performed.
Type
Error
Returns:
A promise that resolves when the mouse has moved by the specified offset.
Type: 
Promise.<void>

(async) bySelector(selector) → {Promise.<void>}

Moves the mouse cursor to an element that matches a given CSS selector.
Parameters:
NameTypeDescription
selectorstringThe CSS selector of the element to move to.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the mouse has moved to the element.
Type: 
Promise.<void>

(async) byXpath(xpath) → {Promise.<void>}

Moves the mouse cursor to an element that matches a given XPath selector.
Parameters:
NameTypeDescription
xpathstringThe XPath selector of the element to move to.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the mouse has moved to the element.
Type: 
Promise.<void>

(async) toPosition(xPos, yPos) → {Promise.<void>}

Moves the mouse cursor to a specific position on the screen.
Parameters:
NameTypeDescription
xPosnumberThe x-coordinate on the screen to move to.
yPosnumberThe y-coordinate on the screen to move to.
Throws:
Throws an error if the action cannot be performed.
Type
Error
Returns:
A promise that resolves when the mouse has moved to the specified position.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/Navigation.html b/docs/documentation/sitespeed.io/scripting/Navigation.html index 11b1b8ade..36c4ebfba 100644 --- a/docs/documentation/sitespeed.io/scripting/Navigation.html +++ b/docs/documentation/sitespeed.io/scripting/Navigation.html @@ -1,3 +1,3 @@ Class: Navigation
On this page

Navigation

Provides functionality to control browser navigation such as back, forward, and refresh actions.

Classes

Navigation

Methods

(async) back(optionsopt) → {Promise.<void>}

Navigates backward in the browser's history.
Parameters:
NameTypeAttributesDescription
optionsObject<optional>
Additional options for navigation. Set {wait:true} to wait for the page complete check to run.
Throws:
Throws an error if navigation fails.
Type
Error
Returns:
A promise that resolves when the navigation action is completed.
Type: 
Promise.<void>

(async) forward(optionsopt) → {Promise.<void>}

Navigates forward in the browser's history.
Parameters:
NameTypeAttributesDescription
optionsObject<optional>
Additional options for navigation. Set {wait:true} to wait for the page complete check to run.
Throws:
Throws an error if navigation fails.
Type
Error
Returns:
A promise that resolves when the navigation action is completed.
Type: 
Promise.<void>

(async) refresh(optionsopt) → {Promise.<void>}

Refreshes the current page.
Parameters:
NameTypeAttributesDescription
optionsObject<optional>
Additional options for refresh action. Set {wait:true} to wait for the page complete check to run.
Throws:
Throws an error if refreshing the page fails.
Type
Error
Returns:
A promise that resolves when the page has been refreshed.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file +
On this page

Navigation

Provides functionality to control browser navigation such as back, forward, and refresh actions.

Classes

Navigation

Methods

(async) back(optionsopt) → {Promise.<void>}

Navigates backward in the browser's history.
Parameters:
NameTypeAttributesDescription
optionsObject<optional>
Additional options for navigation. Set {wait:true} to wait for the page complete check to run.
Throws:
Throws an error if navigation fails.
Type
Error
Returns:
A promise that resolves when the navigation action is completed.
Type: 
Promise.<void>

(async) forward(optionsopt) → {Promise.<void>}

Navigates forward in the browser's history.
Parameters:
NameTypeAttributesDescription
optionsObject<optional>
Additional options for navigation. Set {wait:true} to wait for the page complete check to run.
Throws:
Throws an error if navigation fails.
Type
Error
Returns:
A promise that resolves when the navigation action is completed.
Type: 
Promise.<void>

(async) refresh(optionsopt) → {Promise.<void>}

Refreshes the current page.
Parameters:
NameTypeAttributesDescription
optionsObject<optional>
Additional options for refresh action. Set {wait:true} to wait for the page complete check to run.
Throws:
Throws an error if refreshing the page fails.
Type
Error
Returns:
A promise that resolves when the page has been refreshed.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/Screenshot.html b/docs/documentation/sitespeed.io/scripting/Screenshot.html index bdd17f1c8..5ef76715f 100644 --- a/docs/documentation/sitespeed.io/scripting/Screenshot.html +++ b/docs/documentation/sitespeed.io/scripting/Screenshot.html @@ -1,3 +1,3 @@ Class: Screenshot
On this page

Screenshot

Take a screenshot. The screenshot will be stored to disk, named by the name provided to the take function.

Classes

Screenshot

Methods

(async) take(name) → {Promise.<Object>}

Takes a screenshot and saves it using the screenshot manager.
Parameters:
NameTypeDescription
namestringThe name to assign to the screenshot file.
Throws:
Throws an error if the name parameter is not provided.
Type
Error
Returns:
A promise that resolves with the screenshot details.
Type: 
Promise.<Object>
Example
async commands.screenshot.take('my_startpage');
sitespeed.io scripting
\ No newline at end of file +
On this page

Screenshot

Take a screenshot. The screenshot will be stored to disk, named by the name provided to the take function.

Classes

Screenshot

Methods

(async) take(name) → {Promise.<Object>}

Takes a screenshot and saves it using the screenshot manager.
Parameters:
NameTypeDescription
namestringThe name to assign to the screenshot file.
Throws:
Throws an error if the name parameter is not provided.
Type
Error
Returns:
A promise that resolves with the screenshot details.
Type: 
Promise.<Object>
Example
async commands.screenshot.take('my_startpage');
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/Scroll.html b/docs/documentation/sitespeed.io/scripting/Scroll.html index 38d5b4750..35d78950a 100644 --- a/docs/documentation/sitespeed.io/scripting/Scroll.html +++ b/docs/documentation/sitespeed.io/scripting/Scroll.html @@ -1,3 +1,3 @@ Class: Scroll
On this page

Scroll

Provides functionality to control page scrolling in the browser.

Classes

Scroll

Methods

(async) byLines(lines) → {Promise.<void>}

Scrolls the page by the specified number of lines. This method is only supported in Firefox.
Parameters:
NameTypeDescription
linesnumberThe number of lines to scroll.
Throws:
Throws an error if not used in Firefox.
Type
Error
Returns:
A promise that resolves when the scrolling action is completed.
Type: 
Promise.<void>

(async) byPages(pages) → {Promise.<void>}

Scrolls the page by the specified number of pages.
Parameters:
NameTypeDescription
pagesnumberThe number of pages to scroll.
Returns:
A promise that resolves when the scrolling action is completed.
Type: 
Promise.<void>

(async) byPixels(Xpixels, Ypixels) → {Promise.<void>}

Scrolls the page by the specified number of pixels.
Parameters:
NameTypeDescription
XpixelsnumberThe number of pixels to scroll horizontally.
YpixelsnumberThe number of pixels to scroll vertically.
Returns:
A promise that resolves when the scrolling action is completed.
Type: 
Promise.<void>

(async) toBottom(delayTimeopt) → {Promise.<void>}

Scrolls to the bottom of the page, scrolling page by page with a delay between each scroll.
Parameters:
NameTypeAttributesDefaultDescription
delayTimenumber<optional>
250The delay time in milliseconds between each scroll.
Returns:
A promise that resolves when the scrolling to the bottom is completed.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file +
On this page

Scroll

Provides functionality to control page scrolling in the browser.

Classes

Scroll

Methods

(async) byLines(lines) → {Promise.<void>}

Scrolls the page by the specified number of lines. This method is only supported in Firefox.
Parameters:
NameTypeDescription
linesnumberThe number of lines to scroll.
Throws:
Throws an error if not used in Firefox.
Type
Error
Returns:
A promise that resolves when the scrolling action is completed.
Type: 
Promise.<void>

(async) byPages(pages) → {Promise.<void>}

Scrolls the page by the specified number of pages.
Parameters:
NameTypeDescription
pagesnumberThe number of pages to scroll.
Returns:
A promise that resolves when the scrolling action is completed.
Type: 
Promise.<void>

(async) byPixels(Xpixels, Ypixels) → {Promise.<void>}

Scrolls the page by the specified number of pixels.
Parameters:
NameTypeDescription
XpixelsnumberThe number of pixels to scroll horizontally.
YpixelsnumberThe number of pixels to scroll vertically.
Returns:
A promise that resolves when the scrolling action is completed.
Type: 
Promise.<void>

(async) toBottom(delayTimeopt) → {Promise.<void>}

Scrolls to the bottom of the page, scrolling page by page with a delay between each scroll.
Parameters:
NameTypeAttributesDefaultDescription
delayTimenumber<optional>
250The delay time in milliseconds between each scroll.
Returns:
A promise that resolves when the scrolling to the bottom is completed.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/Select.html b/docs/documentation/sitespeed.io/scripting/Select.html index b926dfc01..e1eccdea7 100644 --- a/docs/documentation/sitespeed.io/scripting/Select.html +++ b/docs/documentation/sitespeed.io/scripting/Select.html @@ -1,3 +1,3 @@ Class: Select
On this page

Select

Provides functionality to interact with `

Classes

Select

Methods

(async) deselectById(selectId) → {Promise.<void>}

Deselects all options in a `
Parameters:
NameTypeDescription
selectIdstringThe ID of the `
Throws:
Throws an error if the `
Type
Error
Returns:
A promise that resolves when all options are deselected.
Type: 
Promise.<void>

(async) getSelectedValueById(selectId) → {Promise.<string>}

Retrieves the value of the selected option in a `
Parameters:
NameTypeDescription
selectIdstringThe ID of the `
Throws:
Throws an error if the `
Type
Error
Returns:
A promise that resolves with the value of the selected option.
Type: 
Promise.<string>

(async) getValuesById(selectId) → {Promise.<Array.<string>>}

Retrieves all option values in a `
Parameters:
NameTypeDescription
selectIdstringThe ID of the `
Throws:
Throws an error if the `
Type
Error
Returns:
A promise that resolves with an array of the values of the options.
Type: 
Promise.<Array.<string>>

(async) selectByIdAndIndex(selectId, index) → {Promise.<void>}

Selects an option in a `
Parameters:
NameTypeDescription
selectIdstringThe ID of the `
indexnumberThe index of the option to select.
Throws:
Throws an error if the `
Type
Error
Returns:
A promise that resolves when the option is selected.
Type: 
Promise.<void>

(async) selectByIdAndValue(selectId, value) → {Promise.<void>}

Selects an option in a `
Parameters:
NameTypeDescription
selectIdstringThe ID of the `
valuestringThe value of the option to select.
Throws:
Throws an error if the `
Type
Error
Returns:
A promise that resolves when the option is selected.
Type: 
Promise.<void>

(async) selectByNameAndIndex(selectName, index) → {Promise.<void>}

Selects an option in a `
Parameters:
NameTypeDescription
selectNamestringThe name of the `
indexnumberThe index of the option to select.
Throws:
Throws an error if the `
Type
Error
Returns:
A promise that resolves when the option is selected.
Type: 
Promise.<void>

(async) selectByNameAndValue(selectName, value) → {Promise.<void>}

Selects an option in a `
Parameters:
NameTypeDescription
selectNamestringThe name of the `
valuestringThe value of the option to select.
Throws:
Throws an error if the `
Type
Error
Returns:
A promise that resolves when the option is selected.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file +
On this page

Select

Provides functionality to interact with `

Classes

Select

Methods

(async) deselectById(selectId) → {Promise.<void>}

Deselects all options in a `
Parameters:
NameTypeDescription
selectIdstringThe ID of the `
Throws:
Throws an error if the `
Type
Error
Returns:
A promise that resolves when all options are deselected.
Type: 
Promise.<void>

(async) getSelectedValueById(selectId) → {Promise.<string>}

Retrieves the value of the selected option in a `
Parameters:
NameTypeDescription
selectIdstringThe ID of the `
Throws:
Throws an error if the `
Type
Error
Returns:
A promise that resolves with the value of the selected option.
Type: 
Promise.<string>

(async) getValuesById(selectId) → {Promise.<Array.<string>>}

Retrieves all option values in a `
Parameters:
NameTypeDescription
selectIdstringThe ID of the `
Throws:
Throws an error if the `
Type
Error
Returns:
A promise that resolves with an array of the values of the options.
Type: 
Promise.<Array.<string>>

(async) selectByIdAndIndex(selectId, index) → {Promise.<void>}

Selects an option in a `
Parameters:
NameTypeDescription
selectIdstringThe ID of the `
indexnumberThe index of the option to select.
Throws:
Throws an error if the `
Type
Error
Returns:
A promise that resolves when the option is selected.
Type: 
Promise.<void>

(async) selectByIdAndValue(selectId, value) → {Promise.<void>}

Selects an option in a `
Parameters:
NameTypeDescription
selectIdstringThe ID of the `
valuestringThe value of the option to select.
Throws:
Throws an error if the `
Type
Error
Returns:
A promise that resolves when the option is selected.
Type: 
Promise.<void>

(async) selectByNameAndIndex(selectName, index) → {Promise.<void>}

Selects an option in a `
Parameters:
NameTypeDescription
selectNamestringThe name of the `
indexnumberThe index of the option to select.
Throws:
Throws an error if the `
Type
Error
Returns:
A promise that resolves when the option is selected.
Type: 
Promise.<void>

(async) selectByNameAndValue(selectName, value) → {Promise.<void>}

Selects an option in a `
Parameters:
NameTypeDescription
selectNamestringThe name of the `
valuestringThe value of the option to select.
Throws:
Throws an error if the `
Type
Error
Returns:
A promise that resolves when the option is selected.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/Set.html b/docs/documentation/sitespeed.io/scripting/Set.html index f7e3fa88e..9f41e0330 100644 --- a/docs/documentation/sitespeed.io/scripting/Set.html +++ b/docs/documentation/sitespeed.io/scripting/Set.html @@ -1,3 +1,3 @@ Class: Set
On this page

Set

Provides functionality to set properties like innerHTML, innerText, and value on elements in a web page.

Classes

Set

Methods

(async) innerHtml(html, selector) → {Promise.<void>}

Sets the innerHTML of an element using a CSS selector.
Parameters:
NameTypeDescription
htmlstringThe HTML string to set as innerHTML.
selectorstringThe CSS selector of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the innerHTML is set.
Type: 
Promise.<void>

(async) innerHtmlById(html, id) → {Promise.<void>}

Sets the innerHTML of an element using its ID.
Parameters:
NameTypeDescription
htmlstringThe HTML string to set as innerHTML.
idstringThe ID of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the innerHTML is set.
Type: 
Promise.<void>

(async) innerText(text, selector) → {Promise.<void>}

Sets the innerText of an element using a CSS selector.
Parameters:
NameTypeDescription
textstringThe text to set as innerText.
selectorstringThe CSS selector of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the innerText is set.
Type: 
Promise.<void>

(async) innerTextById(text, id) → {Promise.<void>}

Sets the innerText of an element using its ID.
Parameters:
NameTypeDescription
textstringThe text to set as innerText.
idstringThe ID of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the innerText is set.
Type: 
Promise.<void>

(async) value(value, selector) → {Promise.<void>}

Sets the value of an element using a CSS selector.
Parameters:
NameTypeDescription
valuestringThe value to set on the element.
selectorstringThe CSS selector of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the value is set.
Type: 
Promise.<void>

(async) valueById(value, id) → {Promise.<void>}

Sets the value of an element using its ID.
Parameters:
NameTypeDescription
valuestringThe value to set on the element.
idstringThe ID of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the value is set.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file +
On this page

Set

Provides functionality to set properties like innerHTML, innerText, and value on elements in a web page.

Classes

Set

Methods

(async) innerHtml(html, selector) → {Promise.<void>}

Sets the innerHTML of an element using a CSS selector.
Parameters:
NameTypeDescription
htmlstringThe HTML string to set as innerHTML.
selectorstringThe CSS selector of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the innerHTML is set.
Type: 
Promise.<void>

(async) innerHtmlById(html, id) → {Promise.<void>}

Sets the innerHTML of an element using its ID.
Parameters:
NameTypeDescription
htmlstringThe HTML string to set as innerHTML.
idstringThe ID of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the innerHTML is set.
Type: 
Promise.<void>

(async) innerText(text, selector) → {Promise.<void>}

Sets the innerText of an element using a CSS selector.
Parameters:
NameTypeDescription
textstringThe text to set as innerText.
selectorstringThe CSS selector of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the innerText is set.
Type: 
Promise.<void>

(async) innerTextById(text, id) → {Promise.<void>}

Sets the innerText of an element using its ID.
Parameters:
NameTypeDescription
textstringThe text to set as innerText.
idstringThe ID of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the innerText is set.
Type: 
Promise.<void>

(async) value(value, selector) → {Promise.<void>}

Sets the value of an element using a CSS selector.
Parameters:
NameTypeDescription
valuestringThe value to set on the element.
selectorstringThe CSS selector of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the value is set.
Type: 
Promise.<void>

(async) valueById(value, id) → {Promise.<void>}

Sets the value of an element using its ID.
Parameters:
NameTypeDescription
valuestringThe value to set on the element.
idstringThe ID of the element.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the value is set.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/SingleClick.html b/docs/documentation/sitespeed.io/scripting/SingleClick.html index 7778db916..162341d3a 100644 --- a/docs/documentation/sitespeed.io/scripting/SingleClick.html +++ b/docs/documentation/sitespeed.io/scripting/SingleClick.html @@ -1,3 +1,3 @@ Class: SingleClick
On this page

SingleClick

Provides functionality to perform a single click action on elements or at specific positions in a web page. Uses Seleniums Action API.

Classes

SingleClick

Methods

(async) atCursor(optionsopt) → {Promise.<void>}

Performs a single mouse click at the current cursor position.
Parameters:
NameTypeAttributesDescription
optionsObject<optional>
Additional options for the click action.
Throws:
Throws an error if the single click action cannot be performed.
Type
Error
Returns:
A promise that resolves when the single click occurs.
Type: 
Promise.<void>

(async) atCursorAndWait() → {Promise.<void>}

Performs a single mouse click at the current cursor position and waits on the page complete check.
Throws:
Throws an error if the single click action cannot be performed.
Type
Error
Returns:
A promise that resolves when the single click occurs.
Type: 
Promise.<void>

(async) byLinkText(text) → {Promise.<void>}

Clicks on a link whose visible text matches the given string.
Parameters:
NameTypeDescription
textstringThe visible text of the link to click.
Throws:
Throws an error if the link is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) byLinkTextAndWait(text) → {Promise.<void>}

Clicks on a link whose visible text matches the given string and waits on the opage complete check.
Parameters:
NameTypeDescription
textstringThe visible text of the link to click.
Throws:
Throws an error if the link is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) byPartialLinkText(text) → {Promise.<void>}

Clicks on a link whose visible text contains the given substring.
Parameters:
NameTypeDescription
textstringThe substring of the visible text of the link to click.
Throws:
Throws an error if the link is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) byPartialLinkTextAndWait(text) → {Promise.<void>}

Clicks on a link whose visible text contains the given substring and waits on the page complete checl.
Parameters:
NameTypeDescription
textstringThe substring of the visible text of the link to click.
Throws:
Throws an error if the link is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) bySelector(selector, optionsopt) → {Promise.<void>}

Performs a single mouse click on an element matching a given CSS selector.
Parameters:
NameTypeAttributesDescription
selectorstringThe CSS selector of the element to click.
optionsObject<optional>
Additional options for the click action.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the single click action is performed.
Type: 
Promise.<void>

(async) bySelectorAndWait(selector) → {Promise.<void>}

Performs a single mouse click on an element matching a given CSS selector and waits on the page complete check.
Parameters:
NameTypeDescription
selectorstringThe CSS selector of the element to click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the single click action is performed.
Type: 
Promise.<void>

(async) byXpath(xpath, optionsopt) → {Promise.<void>}

Performs a single mouse click on an element matching a given XPath selector.
Parameters:
NameTypeAttributesDescription
xpathstringThe XPath selector of the element to click.
optionsObject<optional>
Additional options for the click action.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the single click action is performed.
Type: 
Promise.<void>

(async) byXpathAndWait(xpath) → {Promise.<void>}

Performs a single mouse click on an element matching a given XPath selector and wait for page complete check.
Parameters:
NameTypeDescription
xpathstringThe XPath selector of the element to click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the single click action is performed.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file +
On this page

SingleClick

Provides functionality to perform a single click action on elements or at specific positions in a web page. Uses Seleniums Action API.

Classes

SingleClick

Methods

(async) atCursor(optionsopt) → {Promise.<void>}

Performs a single mouse click at the current cursor position.
Parameters:
NameTypeAttributesDescription
optionsObject<optional>
Additional options for the click action.
Throws:
Throws an error if the single click action cannot be performed.
Type
Error
Returns:
A promise that resolves when the single click occurs.
Type: 
Promise.<void>

(async) atCursorAndWait() → {Promise.<void>}

Performs a single mouse click at the current cursor position and waits on the page complete check.
Throws:
Throws an error if the single click action cannot be performed.
Type
Error
Returns:
A promise that resolves when the single click occurs.
Type: 
Promise.<void>

(async) byLinkText(text) → {Promise.<void>}

Clicks on a link whose visible text matches the given string.
Parameters:
NameTypeDescription
textstringThe visible text of the link to click.
Throws:
Throws an error if the link is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) byLinkTextAndWait(text) → {Promise.<void>}

Clicks on a link whose visible text matches the given string and waits on the opage complete check.
Parameters:
NameTypeDescription
textstringThe visible text of the link to click.
Throws:
Throws an error if the link is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) byPartialLinkText(text) → {Promise.<void>}

Clicks on a link whose visible text contains the given substring.
Parameters:
NameTypeDescription
textstringThe substring of the visible text of the link to click.
Throws:
Throws an error if the link is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) byPartialLinkTextAndWait(text) → {Promise.<void>}

Clicks on a link whose visible text contains the given substring and waits on the page complete checl.
Parameters:
NameTypeDescription
textstringThe substring of the visible text of the link to click.
Throws:
Throws an error if the link is not found.
Type
Error
Returns:
A promise that resolves when the click action is performed.
Type: 
Promise.<void>

(async) bySelector(selector, optionsopt) → {Promise.<void>}

Performs a single mouse click on an element matching a given CSS selector.
Parameters:
NameTypeAttributesDescription
selectorstringThe CSS selector of the element to click.
optionsObject<optional>
Additional options for the click action.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the single click action is performed.
Type: 
Promise.<void>

(async) bySelectorAndWait(selector) → {Promise.<void>}

Performs a single mouse click on an element matching a given CSS selector and waits on the page complete check.
Parameters:
NameTypeDescription
selectorstringThe CSS selector of the element to click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the single click action is performed.
Type: 
Promise.<void>

(async) byXpath(xpath, optionsopt) → {Promise.<void>}

Performs a single mouse click on an element matching a given XPath selector.
Parameters:
NameTypeAttributesDescription
xpathstringThe XPath selector of the element to click.
optionsObject<optional>
Additional options for the click action.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the single click action is performed.
Type: 
Promise.<void>

(async) byXpathAndWait(xpath) → {Promise.<void>}

Performs a single mouse click on an element matching a given XPath selector and wait for page complete check.
Parameters:
NameTypeDescription
xpathstringThe XPath selector of the element to click.
Throws:
Throws an error if the element is not found.
Type
Error
Returns:
A promise that resolves when the single click action is performed.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/StopWatch.html b/docs/documentation/sitespeed.io/scripting/StopWatch.html index 9f44d9994..7e83225ed 100644 --- a/docs/documentation/sitespeed.io/scripting/StopWatch.html +++ b/docs/documentation/sitespeed.io/scripting/StopWatch.html @@ -1,3 +1,3 @@ Class: StopWatch
On this page

StopWatch

A stopwatch utility for measuring time intervals.

Classes

StopWatch

Methods

getName() → {string}

Gets the name of the stopwatch.
Returns:
The name of the stopwatch.
Type: 
string

start()

Starts the stopwatch.

stop() → {number}

Stops the stopwatch.
Returns:
The measured time in milliseconds.
Type: 
number

stopAndAdd() → {number}

Stops the stopwatch and automatically adds the measured time to the last measured page. Logs an error if no page has been measured.
Returns:
The measured time in milliseconds.
Type: 
number
sitespeed.io scripting
\ No newline at end of file +
On this page

StopWatch

A stopwatch utility for measuring time intervals.

Classes

StopWatch

Methods

getName() → {string}

Gets the name of the stopwatch.
Returns:
The name of the stopwatch.
Type: 
string

start()

Starts the stopwatch.

stop() → {number}

Stops the stopwatch.
Returns:
The measured time in milliseconds.
Type: 
number

stopAndAdd() → {number}

Stops the stopwatch and automatically adds the measured time to the last measured page. Logs an error if no page has been measured.
Returns:
The measured time in milliseconds.
Type: 
number
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/Switch.html b/docs/documentation/sitespeed.io/scripting/Switch.html index 299943db5..edf7c4d75 100644 --- a/docs/documentation/sitespeed.io/scripting/Switch.html +++ b/docs/documentation/sitespeed.io/scripting/Switch.html @@ -1,3 +1,3 @@ Class: Switch
On this page

Switch

Provides functionality to switch between frames, windows, and tabs in the browser.

Classes

Switch

Methods

(async) toFrame(id)

Switches to a frame identified by its ID.
Parameters:
NameTypeDescription
idstring | numberThe ID of the frame.
Throws:
Throws an error if switching to the frame fails.
Type
Error

(async) toFrameBySelector(selector)

Switches to a frame identified by a CSS selector.
Parameters:
NameTypeDescription
selectorstringThe CSS selector of the frame element.
Throws:
Throws an error if the frame is not found or switching fails.
Type
Error

(async) toFrameByXpath(xpath)

Switches to a frame identified by an XPath.
Parameters:
NameTypeDescription
xpathstringThe XPath of the frame element.
Throws:
Throws an error if the frame is not found or switching fails.
Type
Error

(async) toNewTab(urlopt)

Opens a new tab and optionally navigates to a URL.
Parameters:
NameTypeAttributesDescription
urlstring<optional>
Optional URL to navigate to in the new tab.
Throws:
Throws an error if opening a new tab fails.
Type
Error

(async) toNewWindow(urlopt)

Opens a new window and optionally navigates to a URL.
Parameters:
NameTypeAttributesDescription
urlstring<optional>
Optional URL to navigate to in the new window.
Throws:
Throws an error if opening a new window fails.
Type
Error

(async) toParentFrame()

Switches to the parent frame of the current frame.
Throws:
Throws an error if switching to the parent frame fails.
Type
Error

(async) toWindow(name)

Switches to a window identified by its name.
Parameters:
NameTypeDescription
namestringThe name of the window.
Throws:
Throws an error if switching to the window fails.
Type
Error
sitespeed.io scripting
\ No newline at end of file +
On this page

Switch

Provides functionality to switch between frames, windows, and tabs in the browser.

Classes

Switch

Methods

(async) toFrame(id)

Switches to a frame identified by its ID.
Parameters:
NameTypeDescription
idstring | numberThe ID of the frame.
Throws:
Throws an error if switching to the frame fails.
Type
Error

(async) toFrameBySelector(selector)

Switches to a frame identified by a CSS selector.
Parameters:
NameTypeDescription
selectorstringThe CSS selector of the frame element.
Throws:
Throws an error if the frame is not found or switching fails.
Type
Error

(async) toFrameByXpath(xpath)

Switches to a frame identified by an XPath.
Parameters:
NameTypeDescription
xpathstringThe XPath of the frame element.
Throws:
Throws an error if the frame is not found or switching fails.
Type
Error

(async) toNewTab(urlopt)

Opens a new tab and optionally navigates to a URL.
Parameters:
NameTypeAttributesDescription
urlstring<optional>
Optional URL to navigate to in the new tab.
Throws:
Throws an error if opening a new tab fails.
Type
Error

(async) toNewWindow(urlopt)

Opens a new window and optionally navigates to a URL.
Parameters:
NameTypeAttributesDescription
urlstring<optional>
Optional URL to navigate to in the new window.
Throws:
Throws an error if opening a new window fails.
Type
Error

(async) toParentFrame()

Switches to the parent frame of the current frame.
Throws:
Throws an error if switching to the parent frame fails.
Type
Error

(async) toWindow(name)

Switches to a window identified by its name.
Parameters:
NameTypeDescription
namestringThe name of the window.
Throws:
Throws an error if switching to the window fails.
Type
Error
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/Wait.html b/docs/documentation/sitespeed.io/scripting/Wait.html index 6243f71d9..69867f0e2 100644 --- a/docs/documentation/sitespeed.io/scripting/Wait.html +++ b/docs/documentation/sitespeed.io/scripting/Wait.html @@ -1,3 +1,3 @@ Class: Wait
On this page

Wait

Provides functionality to wait for different conditions in the browser.

Classes

Wait

Methods

(async) byCondition(jsExpression, maxTime) → {Promise.<void>}

Waits for a JavaScript condition to return a truthy value within a maximum time.
Parameters:
NameTypeDescription
jsExpressionstringThe JavaScript expression to evaluate.
maxTimenumberMaximum time to wait in milliseconds.
Throws:
Throws an error if the condition is not met within the specified time.
Type
Error
Returns:
A promise that resolves when the condition becomes truthy or the time times out.
Type: 
Promise.<void>

(async) byId(id, maxTime) → {Promise.<void>}

Waits for an element with a specific ID to appear within a maximum time.
Parameters:
NameTypeDescription
idstringThe ID of the element to wait for.
maxTimenumberMaximum time to wait in milliseconds.
Throws:
Throws an error if the element is not found within the specified time.
Type
Error
Returns:
A promise that resolves when the element is found or the time times out.
Type: 
Promise.<void>

(async) byPageToComplete() → {Promise.<void>}

Waits for the page to finish loading.
Returns:
A promise that resolves when the page complete check has finished.
Type: 
Promise.<void>
Example
async commands.wait.byPageToComplete();

(async) bySelector(selector, maxTime) → {Promise.<void>}

Waits for an element located by a CSS selector to appear within a maximum time.
Parameters:
NameTypeDescription
selectorstringThe CSS selector of the element to wait for.
maxTimenumberMaximum time to wait in milliseconds.
Throws:
Throws an error if the element is not found within the specified time.
Type
Error
Returns:
A promise that resolves when the element is found or the time times out.
Type: 
Promise.<void>

(async) byTime(ms) → {Promise.<void>}

Waits for a specified amount of time.
Parameters:
NameTypeDescription
msnumberThe time in milliseconds to wait.
Returns:
A promise that resolves when the specified time has elapsed.
Type: 
Promise.<void>
Example
async commands.wait.byTime(1000);

(async) byXpath(xpath, maxTime) → {Promise.<void>}

Waits for an element located by XPath to appear within a maximum time.
Parameters:
NameTypeDescription
xpathstringThe XPath of the element to wait for.
maxTimenumberMaximum time to wait in milliseconds.
Throws:
Throws an error if the element is not found within the specified time.
Type
Error
Returns:
A promise that resolves when the element is found or the time times out.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file +
On this page

Wait

Provides functionality to wait for different conditions in the browser.

Classes

Wait

Methods

(async) byCondition(jsExpression, maxTime) → {Promise.<void>}

Waits for a JavaScript condition to return a truthy value within a maximum time.
Parameters:
NameTypeDescription
jsExpressionstringThe JavaScript expression to evaluate.
maxTimenumberMaximum time to wait in milliseconds.
Throws:
Throws an error if the condition is not met within the specified time.
Type
Error
Returns:
A promise that resolves when the condition becomes truthy or the time times out.
Type: 
Promise.<void>

(async) byId(id, maxTime) → {Promise.<void>}

Waits for an element with a specific ID to appear within a maximum time.
Parameters:
NameTypeDescription
idstringThe ID of the element to wait for.
maxTimenumberMaximum time to wait in milliseconds.
Throws:
Throws an error if the element is not found within the specified time.
Type
Error
Returns:
A promise that resolves when the element is found or the time times out.
Type: 
Promise.<void>

(async) byPageToComplete() → {Promise.<void>}

Waits for the page to finish loading.
Returns:
A promise that resolves when the page complete check has finished.
Type: 
Promise.<void>
Example
async commands.wait.byPageToComplete();

(async) bySelector(selector, maxTime) → {Promise.<void>}

Waits for an element located by a CSS selector to appear within a maximum time.
Parameters:
NameTypeDescription
selectorstringThe CSS selector of the element to wait for.
maxTimenumberMaximum time to wait in milliseconds.
Throws:
Throws an error if the element is not found within the specified time.
Type
Error
Returns:
A promise that resolves when the element is found or the time times out.
Type: 
Promise.<void>

(async) byTime(ms) → {Promise.<void>}

Waits for a specified amount of time.
Parameters:
NameTypeDescription
msnumberThe time in milliseconds to wait.
Returns:
A promise that resolves when the specified time has elapsed.
Type: 
Promise.<void>
Example
async commands.wait.byTime(1000);

(async) byXpath(xpath, maxTime) → {Promise.<void>}

Waits for an element located by XPath to appear within a maximum time.
Parameters:
NameTypeDescription
xpathstringThe XPath of the element to wait for.
maxTimenumberMaximum time to wait in milliseconds.
Throws:
Throws an error if the element is not found within the specified time.
Type
Error
Returns:
A promise that resolves when the element is found or the time times out.
Type: 
Promise.<void>
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/index.html b/docs/documentation/sitespeed.io/scripting/index.html index 5bb80e529..83269f6e5 100644 --- a/docs/documentation/sitespeed.io/scripting/index.html +++ b/docs/documentation/sitespeed.io/scripting/index.html @@ -1,3 +1,3 @@ Tutorials and documentation for scripting in Browsertime and sitespeed.io
On this page

Scripting

The user journey

Welcome to the powerful world of scripting with sitespeed.io! This feature unlocks the potential to simulate real user journeys, measure performance, and gather detailed metrics by interacting with web pages through custom scripts. Whether you're looking to analyze simple page loads or complex user interactions, our scripting functionality offers the tools you need.

Key Features

  • User Journey Simulation: Script entire user flows, from navigation to clicks and form submissions, to capture a realistic user experience.
  • Performance Metrics Collection: Gather crucial data like load times, visual metrics, and more, for each step of your user journey.
  • Flexible Scripting Language: Write scripts in NodeJS, using familiar JavaScript syntax and robust libraries.

Getting Started

Dive into scripting with our tutorials, examples, and documentation for all commands.

sitespeed.io scripting
\ No newline at end of file +
On this page

Scripting

The user journey

Welcome to the powerful world of scripting with sitespeed.io! This feature unlocks the potential to simulate real user journeys, measure performance, and gather detailed metrics by interacting with web pages through custom scripts. Whether you're looking to analyze simple page loads or complex user interactions, our scripting functionality offers the tools you need.

Key Features

  • User Journey Simulation: Script entire user flows, from navigation to clicks and form submissions, to capture a realistic user experience.
  • Performance Metrics Collection: Gather crucial data like load times, visual metrics, and more, for each step of your user journey.
  • Flexible Scripting Language: Write scripts in NodeJS, using familiar JavaScript syntax and robust libraries.

Getting Started

Dive into scripting with our tutorials, examples, and documentation for all commands.

sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/tutorial-01-Introduction.html b/docs/documentation/sitespeed.io/scripting/tutorial-01-Introduction.html index 8577add7c..f17488bd9 100644 --- a/docs/documentation/sitespeed.io/scripting/tutorial-01-Introduction.html +++ b/docs/documentation/sitespeed.io/scripting/tutorial-01-Introduction.html @@ -1,6 +1,6 @@ Tutorial: Introduction
On this page

Introduction

Scripting in sitespeed.io and Browsertime allows you to measure user journeys by interacting with web pages. This feature is essential for simulating real-user interactions and collecting performance metrics for complex workflows. Scripting works the same in both Browsertime and sitespeed.io.

Simple script

Here's a basic script example to start with:

/**
+    
On this page

Introduction

Scripting in sitespeed.io and Browsertime allows you to measure user journeys by interacting with web pages. This feature is essential for simulating real-user interactions and collecting performance metrics for complex workflows. Scripting works the same in both Browsertime and sitespeed.io.

Simple script

Here's a basic script example to start with:

/**
  * @param {import('browsertime').BrowsertimeContext} context
  * @param {import('browsertime').BrowsertimeCommands} commands
  */
@@ -16,4 +16,4 @@ export default async function (context, commands) {
   await commands.navigate('https://www.sitespeed.io');
   return commands.measure.start('https://www.sitespeed.io/documentation/');
 }
-
\ No newline at end of file +
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/tutorial-02-Running-Scripts.html b/docs/documentation/sitespeed.io/scripting/tutorial-02-Running-Scripts.html index 2ad3ee0b8..db9775288 100644 --- a/docs/documentation/sitespeed.io/scripting/tutorial-02-Running-Scripts.html +++ b/docs/documentation/sitespeed.io/scripting/tutorial-02-Running-Scripts.html @@ -1,6 +1,6 @@ Tutorial: Running and managing scripts
On this page

Running and managing scripts

Run scripts using Browsertime is easy. Create your script and run it like this:

browsertime myScript.mjs
+    
On this page

Running and managing scripts

Run scripts using Browsertime is easy. Create your script and run it like this:

browsertime myScript.mjs
 

And in sitespeed.io you need to add the --multi switch (test multiple pages).

sitespeed.io myScript.mjs --multi
 

Multiple scripts

For multiple scripts, list them all in the command. This approach helps manage complex scripts by splitting them into multiple files.

sitespeed.io login.mjs measureStartPage.mjs logout.mjs --multi
 

Or you can break out code in multiple files.

Create a file to include exampleInclude.mjs

export async function example() {
@@ -26,4 +26,4 @@ export default async function (context, commands) {
   await commands.click.byLinkTextAndWait('Last 30 days');
   await commands.measure.stop();
 };
-

Will result in:

Title and description for a script

\ No newline at end of file +

Will result in:

Title and description for a script

sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/tutorial-03-Measurement-Commands.html b/docs/documentation/sitespeed.io/scripting/tutorial-03-Measurement-Commands.html index f3db2311e..9f3840989 100644 --- a/docs/documentation/sitespeed.io/scripting/tutorial-03-Measurement-Commands.html +++ b/docs/documentation/sitespeed.io/scripting/tutorial-03-Measurement-Commands.html @@ -1,6 +1,6 @@ Tutorial: Measure
On this page

Measure

In sitespeed.io, measurements can be conducted using a meassure command for page navigation performance, gathering various metrics during page load. Alternatively, the StopWatch command is used for measuring arbitrary durations, such as the time taken for certain actions to complete. When you create your script you need to know what you want to measure.

The measure Command

In web performance, "navigation" means switching from one webpage to another. This switch triggers several steps in your browser, like closing the current page, loading new content, and showing the new page fully loaded. In sitespeed.io, the commands.measure function is used to analyze this process. It tracks various performance details from the moment you start moving to a new page until it's completely loaded. This includes how long the page takes to load, how fast resources (like images and scripts) are loaded, and more, giving you a full picture of the navigation's performance.

Use the measure command for measuring page navigation performance. It captures metrics from the start to the end of a page load.

/**
+    
On this page

Measure

In sitespeed.io, measurements can be conducted using a meassure command for page navigation performance, gathering various metrics during page load. Alternatively, the StopWatch command is used for measuring arbitrary durations, such as the time taken for certain actions to complete. When you create your script you need to know what you want to measure.

The measure Command

In web performance, "navigation" means switching from one webpage to another. This switch triggers several steps in your browser, like closing the current page, loading new content, and showing the new page fully loaded. In sitespeed.io, the commands.measure function is used to analyze this process. It tracks various performance details from the moment you start moving to a new page until it's completely loaded. This includes how long the page takes to load, how fast resources (like images and scripts) are loaded, and more, giving you a full picture of the navigation's performance.

Use the measure command for measuring page navigation performance. It captures metrics from the start to the end of a page load.

/**
  * @param {import('browsertime').BrowsertimeContext} context
  * @param {import('browsertime').BrowsertimeCommands} commands
  */
@@ -73,4 +73,4 @@ export default async function (context, commands) {
   await commands.mouse.singleClick.byLinkTextAndWait('Learn');
   return commands.measure.stop();
 }
-

And run it like this: sitespeed.io react.mjs --multi --spa --video --visualMetrics

If you are testing a SPA it's important to add the --spa switch. That helps Browsertime to setup some extra functionality to test that page (like instead of waiting for the onloadEvent to stop the measurement, it waits for silence in the network log).

The Chrome team has the following defintion of a Soft navigation:

  1. The navigation is initiated by a user action.
  2. The navigation results in a visible URL change to the user, and a history change.
  3. The navigation results in a DOM change.

For Browsertime it's important that the URL change, that's how we know that we are measuruing a new page.

If your page do not change the URL or load any resources (JSON/JavaScript/CSS or images) when you do the "soft" navigation then you need to use the stop watch to measure that kind of navigation.

\ No newline at end of file +

And run it like this: sitespeed.io react.mjs --multi --spa --video --visualMetrics

If you are testing a SPA it's important to add the --spa switch. That helps Browsertime to setup some extra functionality to test that page (like instead of waiting for the onloadEvent to stop the measurement, it waits for silence in the network log).

The Chrome team has the following defintion of a Soft navigation:

  1. The navigation is initiated by a user action.
  2. The navigation results in a visible URL change to the user, and a history change.
  3. The navigation results in a DOM change.

For Browsertime it's important that the URL change, that's how we know that we are measuruing a new page.

If your page do not change the URL or load any resources (JSON/JavaScript/CSS or images) when you do the "soft" navigation then you need to use the stop watch to measure that kind of navigation.

sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/tutorial-04-Interact-with-the-page.html b/docs/documentation/sitespeed.io/scripting/tutorial-04-Interact-with-the-page.html index 3093fd2d2..ddbbf149e 100644 --- a/docs/documentation/sitespeed.io/scripting/tutorial-04-Interact-with-the-page.html +++ b/docs/documentation/sitespeed.io/scripting/tutorial-04-Interact-with-the-page.html @@ -1,6 +1,6 @@ Tutorial: Interact with the page
On this page

Interact with the page

There are multiple ways to interact with the current page. We have tried to add the most common ways so you don't need to use Selenium directly, and if yoiu think something is missing, please create an issue.

Finding elements

One of the key things in your script is to be able to find the right element to invoke. If the element has an id it’s easy. If not you can use developer tools in your favourite browser. The all work mostly the same: Open DevTools in the page you want to inspect, click on the element and right click on DevTools for that element. Then you will see something like this:

Using Safari to find the CSS Selector to the element

Using Safari to find the selector

Using Firefox to find the CSS Selector to the element

Using Firefox to find the selector{

Using Chrome to find the CSS Selector to the element

Using Chrome to find the selector

Using Actions

Since Browsertime 21.0.0 we support easier access to the Selenium Action API. That makes easier to interact with the page and you can also chain commands. You can checkout the Selenium NodeJS Action API to see more what you can do.

Here's an example doing search on Wikipedia:

/**
+    
On this page

Interact with the page

There are multiple ways to interact with the current page. We have tried to add the most common ways so you don't need to use Selenium directly, and if yoiu think something is missing, please create an issue.

Finding elements

One of the key things in your script is to be able to find the right element to invoke. If the element has an id it’s easy. If not you can use developer tools in your favourite browser. The all work mostly the same: Open DevTools in the page you want to inspect, click on the element and right click on DevTools for that element. Then you will see something like this:

Using Safari to find the CSS Selector to the element

Using Safari to find the selector

Using Firefox to find the CSS Selector to the element

Using Firefox to find the selector{

Using Chrome to find the CSS Selector to the element

Using Chrome to find the selector

Using Actions

Since Browsertime 21.0.0 we support easier access to the Selenium Action API. That makes easier to interact with the page and you can also chain commands. You can checkout the Selenium NodeJS Action API to see more what you can do.

Here's an example doing search on Wikipedia:

/**
  * @param {import('browsertime').BrowsertimeContext} context
  * @param {import('browsertime').BrowsertimeCommands} commands
  */
@@ -66,4 +66,4 @@ export default async function (context, commands) {
   return commands.measure.stop();
 };
 

Add text

You can add text to input elements. The element needs to visible. You can also send pressable keys as Unicode PUA (PrivateUser Area) format.

The add text command.

Switch

You can switch to frames/windows or tabs using the the switch commands.

Set

Using the set commands you can set values to HTML elements.

Select

You can use the select command for selecting an option in a drop-down field.

Alert boxes

If you need to click on an alert box, the best way is to use Selenium directly. Here's an example on how to accept an alert box.

await context.selenium.driver.switchTo().alert().accept();
-
\ No newline at end of file +
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/tutorial-05-Interact-Browser.html b/docs/documentation/sitespeed.io/scripting/tutorial-05-Interact-Browser.html index ee940407b..1f3e7eabb 100644 --- a/docs/documentation/sitespeed.io/scripting/tutorial-05-Interact-Browser.html +++ b/docs/documentation/sitespeed.io/scripting/tutorial-05-Interact-Browser.html @@ -1,6 +1,6 @@ Tutorial: Interact with the browser
On this page

Interact with the browser

You can navigate to a URL without measuring it. You do it with the navigate function. Navigation will use the same logic as measuring, it will wait for the page complete check to finish.

/**
+    
On this page

Interact with the browser

You can navigate to a URL without measuring it. You do it with the navigate function. Navigation will use the same logic as measuring, it will wait for the page complete check to finish.

/**
  * @param {import('browsertime').BrowsertimeContext} context
  * @param {import('browsertime').BrowsertimeCommands} commands
  */
@@ -28,4 +28,4 @@ export default async function (context, commands) {
   await commands.cache.clearKeepCookies();
   // and then access the URL you wanna test.
 }
-

You can use the Navigation command to go back, forward or refresh the page in the browser.

\ No newline at end of file +

You can use the Navigation command to go back, forward or refresh the page in the browser.

sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/tutorial-06-Error-handling.html b/docs/documentation/sitespeed.io/scripting/tutorial-06-Error-handling.html index 917435470..3b1a3e58d 100644 --- a/docs/documentation/sitespeed.io/scripting/tutorial-06-Error-handling.html +++ b/docs/documentation/sitespeed.io/scripting/tutorial-06-Error-handling.html @@ -1,6 +1,6 @@ Tutorial: Error handling
On this page

Error handling

You can try/catch failing commands that throw errors. If an error is not caught in your script, it will be caught in sitespeed.io and the error will be logged and reported in the HTML and to your data storage (Graphite/InfluxDb) under the key browsertime.statistics.errors.

If you do catch the error, you should make sure you report it yourself with the error function, so you can see that in the HTML report. This is needed for all errors except navigating/measuring a URL. They will automatically be reported (since they are always important).

If you measuring a page in a user journey and it fails, you can stop your measurements as a error and not collect any metrics. This works from Browsertime 21.2.0 and sitespeed.io 33.0.0.

/**
+    
On this page

Error handling

You can try/catch failing commands that throw errors. If an error is not caught in your script, it will be caught in sitespeed.io and the error will be logged and reported in the HTML and to your data storage (Graphite/InfluxDb) under the key browsertime.statistics.errors.

If you do catch the error, you should make sure you report it yourself with the error function, so you can see that in the HTML report. This is needed for all errors except navigating/measuring a URL. They will automatically be reported (since they are always important).

If you measuring a page in a user journey and it fails, you can stop your measurements as a error and not collect any metrics. This works from Browsertime 21.2.0 and sitespeed.io 33.0.0.

/**
  * @param {import('browsertime').BrowsertimeContext} context
  * @param {import('browsertime').BrowsertimeCommands} commands
  */
@@ -52,4 +52,4 @@ export default async function (context, commands) {
     await commands.screenshot.take('my-failure');
   }
  }
-
\ No newline at end of file +
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/tutorial-07-Debugging-Scripts.html b/docs/documentation/sitespeed.io/scripting/tutorial-07-Debugging-Scripts.html index 474db7b43..110237672 100644 --- a/docs/documentation/sitespeed.io/scripting/tutorial-07-Debugging-Scripts.html +++ b/docs/documentation/sitespeed.io/scripting/tutorial-07-Debugging-Scripts.html @@ -1,6 +1,6 @@ Tutorial: Debugging scripts
On this page

Debugging scripts

There are a couple of ways of debugging your scripts.

Use the log

The easist way know what's going on is log to the browsertime/sitespeed.io log. You can do that with log object that exist in the context object.

/**
+    
On this page

Debugging scripts

There are a couple of ways of debugging your scripts.

Use the log

The easist way know what's going on is log to the browsertime/sitespeed.io log. You can do that with log object that exist in the context object.

/**
  * @param {import('browsertime').BrowsertimeContext} context
  * @param {import('browsertime').BrowsertimeCommands} commands
  */
@@ -45,4 +45,4 @@ export default async function (context, commands) {
     await commands.measure.stopAsError('Could not click the next page link');
   }
  }
-
\ No newline at end of file +
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/tutorial-08-Setting-Up-IntelliSense.html b/docs/documentation/sitespeed.io/scripting/tutorial-08-Setting-Up-IntelliSense.html index 3cedea480..af95cfd87 100644 --- a/docs/documentation/sitespeed.io/scripting/tutorial-08-Setting-Up-IntelliSense.html +++ b/docs/documentation/sitespeed.io/scripting/tutorial-08-Setting-Up-IntelliSense.html @@ -1,6 +1,6 @@ Tutorial: Code completion and IntelliSense
On this page

Code completion and IntelliSense

IntelliSense in Visual Studio Code can significantly enhance your scripting experience with Browsertime and sitespeed.io by providing code completions, parameter info, quick info, and member lists. Here's how to set it up.

Prerequisites

Before starting, ensure that you have NodeJS and npm installed on your system. You can download them from NodeJS official website.

Step 1: Create a New Project

  1. Create a new directory for your project.
  2. Open a terminal and navigate to your project directory.
  3. Run the following command to initialize a new npm project: npm init
  4. Follow the prompts to set up your project.

Step 2: Install Browsertime

To install Browsertime and its types, use npm. In your project directory, run:

npm install browsertime --save-dev
+    
On this page

Code completion and IntelliSense

IntelliSense in Visual Studio Code can significantly enhance your scripting experience with Browsertime and sitespeed.io by providing code completions, parameter info, quick info, and member lists. Here's how to set it up.

Prerequisites

Before starting, ensure that you have NodeJS and npm installed on your system. You can download them from NodeJS official website.

Step 1: Create a New Project

  1. Create a new directory for your project.
  2. Open a terminal and navigate to your project directory.
  3. Run the following command to initialize a new npm project: npm init
  4. Follow the prompts to set up your project.

Step 2: Install Browsertime

To install Browsertime and its types, use npm. In your project directory, run:

npm install browsertime --save-dev
 

This command installs Browsertime as a developer dependency.

Step 3: Configure Visual Studio Code

  1. In Visual Studio Code, open your project.
  2. Go to Settings (use Ctrl + , or Cmd + , on Mac).
  3. Search for JavaScript › Suggest: Names.
  4. Disable this setting. This helps in ensuring that IntelliSense only suggests existing properties and functions related to Browsertime objects.

Step 4: Reload Visual Studio Code

After making these changes, reload Visual Studio Code to apply the new settings.

Step 5: Start Scripting

Now, as you write your Browsertime scripts, IntelliSense will assist you as long as you add the correct parameters. It automatically suggests relevant methods and properties. Here's a template to get you started:

/**
  * @param {import('browsertime').BrowsertimeContext} context
  * @param {import('browsertime').BrowsertimeCommands} commands
@@ -24,4 +24,4 @@ export default async function (context, commands) {
     "description": "Sitespeed.io scripting"
   }
 }
-

Replace "sitespeed.ioScripting" with your preferred prefix that will trigger the snippet.

  1. Save the Snippets File: Save the file (Ctrl + S or Cmd + S).
\ No newline at end of file +

Replace "sitespeed.ioScripting" with your preferred prefix that will trigger the snippet.

  1. Save the Snippets File: Save the file (Ctrl + S or Cmd + S).
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/tutorial-09-Examples.html b/docs/documentation/sitespeed.io/scripting/tutorial-09-Examples.html index 21e955b85..11a9e44a1 100644 --- a/docs/documentation/sitespeed.io/scripting/tutorial-09-Examples.html +++ b/docs/documentation/sitespeed.io/scripting/tutorial-09-Examples.html @@ -1,6 +1,6 @@ Tutorial: Examples
On this page

Examples

Here are some examples on how you can use the scripting capabilities.

Measure multiple pages

Test multiple pages in a script:

/**
+    
On this page

Examples

Here are some examples on how you can use the scripting capabilities.

Measure multiple pages

Test multiple pages in a script:

/**
  * @param {import('browsertime').BrowsertimeContext} context
  * @param {import('browsertime').BrowsertimeCommands} commands
  */
@@ -304,4 +304,4 @@ module.exports = async function (context, commands) {
     "urls": ["url1", "url2", "url3"]
   }
 }
-
\ No newline at end of file +
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/tutorial-10-Selenium.html b/docs/documentation/sitespeed.io/scripting/tutorial-10-Selenium.html index 495a8cf83..20fcb28e6 100644 --- a/docs/documentation/sitespeed.io/scripting/tutorial-10-Selenium.html +++ b/docs/documentation/sitespeed.io/scripting/tutorial-10-Selenium.html @@ -1,6 +1,6 @@ Tutorial: Running Selenium code
On this page

Running Selenium code

You can use Selenium directly if you need to use things that are not available through our commands. We use the NodeJS flavor of Selenium.

You get a hold of the Selenium objects through the context object.

The selenium.webdriver is the Selenium WebDriver public API object. And selenium.driver is the instantiated version of the WebDriver driving the current version of the browser.

Checkout this example to see how you can use them.

/**
+    
On this page

Running Selenium code

You can use Selenium directly if you need to use things that are not available through our commands. We use the NodeJS flavor of Selenium.

You get a hold of the Selenium objects through the context object.

The selenium.webdriver is the Selenium WebDriver public API object. And selenium.driver is the instantiated version of the WebDriver driving the current version of the browser.

Checkout this example to see how you can use them.

/**
  * @param {import('browsertime').BrowsertimeContext} context
  * @param {import('browsertime').BrowsertimeCommands} commands
  */
@@ -37,4 +37,4 @@ export default async function (context, commands) {
   // Stop the measuerment
   return commands.measure.stop();
 }
-

If you need help with Selenium, checkout the official Selenium documentation.

\ No newline at end of file +

If you need help with Selenium, checkout the official Selenium documentation.

sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/tutorial-11-Chrome-Devtools-Protocol.html b/docs/documentation/sitespeed.io/scripting/tutorial-11-Chrome-Devtools-Protocol.html index f5964420b..7934d053c 100644 --- a/docs/documentation/sitespeed.io/scripting/tutorial-11-Chrome-Devtools-Protocol.html +++ b/docs/documentation/sitespeed.io/scripting/tutorial-11-Chrome-Devtools-Protocol.html @@ -1,6 +1,6 @@ Tutorial: Chrome Devtools Protocol (CDP)
On this page

Chrome Devtools Protocol (CDP)

Send messages to Chrome using the Chrome DevTools Protocol. This only works in Chrome/Edge. You can send, send and get and listen on events. This is a super powerful feature that enables you to do almost whatever you want with the browser.

Sending a command

Send a command to Chrome and don’t expect something back.

Here’s an example of injecting JavaScript that runs on every new document.

/**
+    
On this page

Chrome Devtools Protocol (CDP)

Send messages to Chrome using the Chrome DevTools Protocol. This only works in Chrome/Edge. You can send, send and get and listen on events. This is a super powerful feature that enables you to do almost whatever you want with the browser.

Sending a command

Send a command to Chrome and don’t expect something back.

Here’s an example of injecting JavaScript that runs on every new document.

/**
  * @param {import('browsertime').BrowsertimeContext} context
  * @param {import('browsertime').BrowsertimeCommands} commands
  */
@@ -68,4 +68,4 @@ export default async function (context, commands) {
   return commands.measure.start('https://www.sitespeed.io/search/');
 }
 
-
\ No newline at end of file +
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/tutorial-12-Bidi.html b/docs/documentation/sitespeed.io/scripting/tutorial-12-Bidi.html new file mode 100644 index 000000000..dcdf23b78 --- /dev/null +++ b/docs/documentation/sitespeed.io/scripting/tutorial-12-Bidi.html @@ -0,0 +1,32 @@ +Tutorial: Using Bidi
On this page

Using Bidi

Send messages to the browser using the BiDirectional WebDriver Protocol (Bidi). This works in Firefox today and later more browsers. You can send, send and get and listen on events. This is a super powerful feature that enables you to do a lot.

There's no user friendly documentation right now for Bidi.

Sending a command

Here’s an example of sending a command that injects JavaScript that runs on every new document.

/**
+ * @param {import('browsertime').BrowsertimeContext} context
+ * @param {import('browsertime').BrowsertimeCommands} commands
+ */
+export default async function (context, commands) {
+  const params = {
+  method: 'script.addPreloadScript',
+  params: {
+    functionDeclaration: "function() {alert('hello');}"
+   }
+  };
+  await commands.bidi.send(params);
+  await commands.measure.start('https://www.sitespeed.io');
+}
+

Subscribe and usubscribe to events

You need to subscribe to the event types that you are interested in with commands.bidi.subscribe('messageType'); and unsubscribe when you are done.

Listen on events

When you subscribe on an event you want to do something when the events happen.

/**
+ * @param {import('browsertime').BrowsertimeContext} context
+ * @param {import('browsertime').BrowsertimeCommands} commands
+ */
+export default async function (context, commands) {
+  // We want to to do something on all the requests that are sent
+  await commands.bidi.subscribe('network.beforeRequestSent');
+
+  await commands.bidi.onMessage(function (event) {
+    const myEvent = JSON.parse(Buffer.from(event.toString()));
+    console.log(myEvent);
+  });
+
+  await commands.navigate('https://www.sitespeed.io');
+}
+
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/tutorial-13-Android.html b/docs/documentation/sitespeed.io/scripting/tutorial-13-Android.html new file mode 100644 index 000000000..65b755adf --- /dev/null +++ b/docs/documentation/sitespeed.io/scripting/tutorial-13-Android.html @@ -0,0 +1,29 @@ +Tutorial: Android devices
On this page

Android devices

Testing on an Android device should work the same way as testing on desktop, as long as you setup your device following the instructions.

Run shell command

If you run your tests on an Android phone you can interact with your phone through the shell.

/**
+ * @param {import('browsertime').BrowsertimeContext} context
+ * @param {import('browsertime').BrowsertimeCommands} commands
+ */
+export default async function (context, commands) {
+  // Get the temperature from the phone
+  const temperature = await commands.android.shell("dumpsys battery | grep temperature | grep -Eo '[0-9]{1,3}'");
+  context.log.info('The battery temperature is %s', temperature/10);
+  // Start the test
+  return commands.measure.start(
+    'https://www.sitespeed.io'
+  );
+};
+

Run shell command as root

If you rooted your device and want to run as root.

/**
+ * @param {import('browsertime').BrowsertimeContext} context
+ * @param {import('browsertime').BrowsertimeCommands} commands
+ */
+export default async function (context, commands) {
+  // Get the temperature from the phone
+  const temperature = await commands.android.shellAsRoot("dumpsys battery | grep temperature | grep -Eo '[0-9]{1,3}'");
+  context.log.info('The battery temperature is %s', temperature/10);
+  // Start the test
+  return commands.measure.start(
+    'https://www.sitespeed.io'
+  );
+};
+
sitespeed.io scripting
\ No newline at end of file diff --git a/docs/documentation/sitespeed.io/scripting/tutorial-18-Tips-and-tricks.html b/docs/documentation/sitespeed.io/scripting/tutorial-18-Tips-and-tricks.html new file mode 100644 index 000000000..d88a8b2ed --- /dev/null +++ b/docs/documentation/sitespeed.io/scripting/tutorial-18-Tips-and-tricks.html @@ -0,0 +1,110 @@ +Tutorial: Tips and tricks
On this page

Tips and tricks

Here are some tips and tricks that can make your scripting better.

Include the script in the HTML result

If you wanna keep of what script you are running, you can include the script into the HTML result with --html.showScript. You will then get a link to a page that show the script.

Page to page

Getting correct Visual Metrics

Visual metrics is the metrics that are collected using the video recording of the screen. In most cases that will work just out of the box. One thing to know is that when you go from one page to another page, the browser keeps the layout of the old page. That means that your video will start with the first page (instead of white) when you navigate to the next page.

It will look like this: Page to page

This is perfectly fine in most cases. But if you want to start white (the metrics somehow isn't correct) or if you click a link and that click changes the layout and is caught as First Visual Change, there are workarounds.

If you just want to start white and navigate to the next page you can just clear the HTML between pages:

/**
+ * @param {import('browsertime').BrowsertimeContext} context
+ * @param {import('browsertime').BrowsertimeCommands} commands
+ */
+export default async function (context, commands) {
+    await commands.measure.start('https://www.sitespeed.io');
+    // Renove the HTML and make sure the background is white
+    await commands.js.run('document.body.innerHTML = ""; document.body.style.backgroundColor = "white";');
+    return commands.measure.start('https://www.sitespeed.io/examples/');
+};
+

If you want to click a link and want to make sure that the HTML doesn't change when you click the link, you can try to hide the HTML and then click the link.

/**
+ * @param {import('browsertime').BrowsertimeContext} context
+ * @param {import('browsertime').BrowsertimeCommands} commands
+ */
+export default async function (context, commands) {
+    await commands.measure.start('https://www.sitespeed.io');
+    // Hide everything
+    // We do not hide the body since the body needs to be visible when we do the magic to find the staret of the
+    // navigation by adding a layer of orange on top of the page
+    await commands.js.run('for (let node of document.body.childNodes) { if (node.style) node.style.display = "none";}');
+    // Start measurning
+    await commands.measure.start();
+    // Click on the link and wait on navigation to happen
+    await commands.click.bySelectorAndWait('body > nav > div > div > div > ul > li:nth-child(2) > a');
+    return commands.measure.stop();
+};
+

Pass your own options to your script

You can add your own parameters to the options object (by adding a parameter) and then pick them up in the script. The scripts runs in the context of browsertime, so you need to pass it in via that context.

For example: you wanna pass on a password to your script, you can do that by adding --browsertime.my.password MY_PASSWORD and then in your code get a hold of that with:

/**
+ * @param {import('browsertime').BrowsertimeContext} context
+ * @param {import('browsertime').BrowsertimeCommands} commands
+ */
+export default async function (context, commands) {
+  // We are in browsertime context so you can skip that from your options object
+  context.log.info(context.options.my.password);
+};
+

If you use a configuration file you can pass on options like this:

{
+    "browsertime": {
+        "my": {
+            "password": "paAssW0rd"
+        }
+    }
+}
+

Getting values from your page

In some scenarios you want to do different things dependent on what shows on your page. For example: You are testing a shop checkout and you need to verify that the item is in stock. You can run JavaScript and get the value back to your script.

Here's an simple example, IRL you will need to get something from the page:

/**
+ * @param {import('browsertime').BrowsertimeContext} context
+ * @param {import('browsertime').BrowsertimeCommands} commands
+ */
+export default async function (context, commands) {
+  // We are in browsertime context so you can skip that from your options object
+  const secretValue = await commands.js.run('return 12');
+  // if secretValue === 12 ...
+}
+

If you want to have different flows depending on a element exists you can do something like this:

...
+const exists = await commands.js.run('return (document.getElementById("nonExistsingID") != null) ');
+if (exists) {
+    // The element with that id exists
+} else {
+    // There's no element with that id
+}
+

Test one page that need a much longer page complete check than others

If you have one page that needs some special handling that maybe do a couple of late and really slow AJAX requests, you can catch that with your on wait for the page to finish.

/**
+ * @param {import('browsertime').BrowsertimeContext} context
+ * @param {import('browsertime').BrowsertimeCommands} commands
+ */
+export default async function (context, commands) {
+  // First test a couple pages with default page complete check
+  await commands.measure.start('https://<page1>');
+  await commands.measure.start('https://<page2>');
+  await commands.measure.start('https://<page3>');
+
+  // Then we have a page that we know need to wait longer, start measuring
+  await command.measure.start('MySpecialPage');
+  // Go to the page
+  await commands.navigate('https://<myspecialpage>');
+  // Then you need to wait on a specific element or event. In this case
+  // we wait for a id to appear but you could also run your custom JS
+  await commands.wait.byId('my-id', 20000);
+  // And then when you know that page has loaded stop the measurement
+  // = stop the video, collect metrics etc
+  return commands.measure.stop();
+};
+

Test the same page multiple times within the same run

If you for some reason want to test the same URL within the same run multiple times, it will not work out of the box since the current version create the result files using the URL. For example testing https://www.sitespeed.io/ two times, will break since the second access will try to overwrite the first one.

But there is a hack you can do. If you add a dummy query parameter (and give the page an alias) you can test them twice.

/**
+ * @param {import('browsertime').BrowsertimeContext} context
+ * @param {import('browsertime').BrowsertimeCommands} commands
+ */
+export default async function (context, commands) {
+    await commands.measure.start('https://www.sitespeed.io/', 'HomePage');
+
+    // Do something smart that then make you need to test the same URL again
+    // ...
+
+    return commands.navigate('https://www.sitespeed.io/?dummy', 'BackToHomepage');
+};
+

Using setUp and tearDown in the same script

This is a feature used by Mozilla and was created years ago. Nowadays you can probably just do everything in one script.

Scripts can also directly define the --preScript and --postScript options by implementing a setUp and/or a tearDown function. These functions will get the same arguments than the test itself. When using this form, the three functions are declared in module.exports under the setUp, tearDown and test keys. This works for commons JS files.

Here's a minimal example:

async function setUp(context, commands) {
+  // do some useful set up
+};
+
+async function perfTest(context, commands) {
+  // add your own code here
+};
+
+async function tearDown(context, commands) {
+  // do some cleanup here
+};
+
+module.exports = {
+  setUp: setUp,
+  tearDown: tearDown,
+  test: perfTest
+};
+
sitespeed.io scripting
\ No newline at end of file