| 1 |
/* This Source Code Form is subject to the terms of the Mozilla Public |
| 2 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 4 |
|
| 5 |
async function test(context, commands) { |
| 6 |
await commands.navigate("https://www.example.com"); |
| 7 |
await commands.wait.byTime(15000); |
| 8 |
|
| 9 |
// Fill in: |
| 10 |
let username = "[email protected]"; |
| 11 |
let passworld = "topsecretpassword"; |
| 12 |
|
| 13 |
// We start by navigating to the login page. |
| 14 |
await commands.navigate("https://www.facebook.com"); |
| 15 |
|
| 16 |
// When we fill in a input field/click on a link we wanna |
| 17 |
// try/catch that if the HTML on the page changes in the feature |
| 18 |
// sitespeed.io will automatically log the error in a user friendly |
| 19 |
// way, and the error will be re-thrown so you can act on it. |
| 20 |
await commands.wait.byTime(5000); |
| 21 |
|
| 22 |
// Add text into an input field, finding the field by id |
| 23 |
await commands.addText.bySelector(username, "input[name=email]"); |
| 24 |
await commands.wait.byTime(2000); |
| 25 |
await commands.addText.bySelector(passworld, "input[name=pass]"); |
| 26 |
await commands.wait.byTime(2000); |
| 27 |
|
| 28 |
// Start the measurement before we click on the |
| 29 |
// submit button. Sitespeed.io will start the video recording |
| 30 |
// and prepare everything. |
| 31 |
// Find the sumbit button and click it and then wait |
| 32 |
// for the pageCompleteCheck to finish |
| 33 |
await commands.measure.start("pageload"); |
| 34 |
|
| 35 |
// There are two variants of the facebook login page: |
| 36 |
try { |
| 37 |
await commands.click.bySelectorAndWait("button[name=login]"); |
| 38 |
} catch (e) { |
| 39 |
await commands.click.bySelectorAndWait("input[type=submit]"); |
| 40 |
} |
| 41 |
|
| 42 |
// Stop and collect the measurement before the next page we want to measure |
| 43 |
await commands.measure.stop(); |
| 44 |
} |
| 45 |
|
| 46 |
module.exports = { |
| 47 |
test, |
| 48 |
owner: "Performance Team", |
| 49 |
name: "Facebook", |
| 50 |
description: "Measures time to log in to Facebook", |
| 51 |
}; |