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 bf7865f43..bdf5d3eaf 100644 --- a/docs/documentation/sitespeed.io/scripting/tutorial-07-Debugging-Scripts.html +++ b/docs/documentation/sitespeed.io/scripting/tutorial-07-Debugging-Scripts.html @@ -30,4 +30,19 @@ export default async function (context, commands) { await commands.screenshot.take('myError'); } } +

If you measure a navigation by clicking on an element and the element do not exists or somnething goes wrong, you can stop the measuerement and make sure no metrics is collected.

/**
+ * @param {import('browsertime').BrowsertimeContext} context
+ * @param {import('browsertime').BrowsertimeCommands} commands
+ */
+export default async function (context, commands) {
+  
+  await commands.measure.start('my_trip');
+  try {
+    // do something that can break
+    await commands.mouse.singleClick.byLinkTextAndWait('Next page');
+    await commands.measure.stop();
+  } catch(error) {
+    await commands.measure.stopAsError('Could not click the next page link');
+  }
+ }
 
sitespeed.io scripting
\ No newline at end of file