16 lines
554 B
TypeScript
16 lines
554 B
TypeScript
import { browser } from '@wdio/globals';
|
|
|
|
export enum DocumentReadyState {
|
|
Loading = 'Loading',
|
|
Interactive = 'Interactive',
|
|
Completed = 'Completed'
|
|
}
|
|
|
|
export async function waitUntilDocumentReadyState(waitForReadyState: DocumentReadyState): Promise<void> {
|
|
await browser.waitUntil(() => browser.execute(`document.readyState === "${DocumentReadyState[waitForReadyState]}"`) as Promise<boolean>, {
|
|
timeout: 10000,
|
|
timeoutMsg: `Document did not have a readyState of [${waitForReadyState}] after [10] seconds`,
|
|
interval: 1000
|
|
});
|
|
}
|