-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
sizeOfElementToBe.ts
27 lines (24 loc) · 1004 Bytes
/
sizeOfElementToBe.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
26
27
import type { StringOrElement } from './../utils/element.types';
import { getElement } from './../utils';
/**
* A condition for checking size of element with given selector
*
* @example
* browser.waitUntil(sizeOfElementsToBe('button', { width: 200, height: 200 }));
*
* @param {!string | ChainablePromiseElement<Element<'async'>>} selectorOrElement The selector or element to check
* @param {!{ width: number, height: number }} expectedSize The selector to check
*
* @returns {!function} An expected condition that returns a promise
* representing whether the element size.
*/
export function sizeOfElementsToBe(
selectorOrElement: StringOrElement,
expectedSize: { width: number; height: number },
): () => Promise<boolean> {
return async function (): Promise<boolean> {
const element = await getElement(selectorOrElement);
const actualSize = await element.getSize();
return actualSize.width === expectedSize.width && actualSize.height === expectedSize.height;
};
}