blob: 3bd7dc220a018d692d097465776761de87aa2731 [file] [log] [blame]
Patrick Brossetdd3309c2020-05-18 13:35:251// Copyright 2020 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Patrick Brosset0805f4a2020-06-11 09:34:325import {$, click, goToResource, waitFor} from '../../shared/helper.js';
Patrick Brossetdd3309c2020-05-18 13:35:256
7const RECORD_BUTTON_SELECTOR = '[aria-label="Record"]';
8const STOP_BUTTON_SELECTOR = '[aria-label="Stop"]';
9
Patrick Brosset60bf7bf2020-06-08 17:04:2910export async function navigateToPerformanceTab(testName?: string) {
11 if (testName) {
Patrick Brosset0805f4a2020-06-11 09:34:3212 await goToResource(`performance/${testName}.html`);
Patrick Brosset60bf7bf2020-06-08 17:04:2913 }
Patrick Brossetdd3309c2020-05-18 13:35:2514
15 // Click on the tab.
16 await click('#tab-timeline');
17
18 // Make sure the landing page is shown.
19 await waitFor('.timeline-landing-page');
20}
21
22export async function startRecording() {
23 await click(RECORD_BUTTON_SELECTOR);
24
Patrick Brosset60bf7bf2020-06-08 17:04:2925 // Wait for the button to turn to its stop state.
26 await waitFor(STOP_BUTTON_SELECTOR);
Patrick Brossetdd3309c2020-05-18 13:35:2527}
28
29export async function stopRecording() {
30 await click(STOP_BUTTON_SELECTOR);
31
32 // Make sure the timeline details panel appears. It's a sure way to assert
33 // that a recording is actually displayed as some of the other elements in
34 // the timeline remain in the DOM even after the recording has been cleared.
35 await waitFor('.timeline-details-chip-body');
36}
37
38export async function getTotalTimeFromSummary(): Promise<number> {
39 const pieChartTotal = await $('.pie-chart-total');
Johan Baye8245712020-08-04 13:32:1040 const totalText = await pieChartTotal.evaluate(node => node.textContent as string);
Patrick Brossetdd3309c2020-05-18 13:35:2541 return parseInt(totalText, 10);
42}
Patrick Brosset60bf7bf2020-06-08 17:04:2943
44export async function navigateToPerformanceSidebarTab(tabName: string) {
45 await click(`[aria-label="${tabName}"]`);
46}
47
48export async function waitForSourceLinkAndFollowIt() {
49 const link = await waitFor('.devtools-link');
50 await click(link);
51 await waitFor('.panel[aria-label="sources"]');
52}