forked from ChromeDevTools/devtools-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsensors-helpers.ts
25 lines (19 loc) · 937 Bytes
/
sensors-helpers.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import type {ElementHandle} from 'puppeteer-core';
import {selectOption, waitFor, waitForMany} from '../../shared/helper.js';
export async function setCustomOrientation() {
const dropDown = await waitFor('.orientation-fields select');
void selectOption(await dropDown.toElement('select'), 'custom');
}
export async function getInputFieldValue(field: ElementHandle<Element>): Promise<string> {
return field.evaluate(input => (input as HTMLInputElement).value);
}
export async function getOrientationInputs() {
return waitForMany('.orientation-axis-input-container input', 3);
}
export async function getOrientationValues() {
return Promise.all(
(await getOrientationInputs()).map(i => i.evaluate(i => parseInt((i as HTMLInputElement).value, 10))));
}