PeerTube/client/e2e/src/utils.ts

35 lines
874 B
TypeScript
Raw Normal View History

2020-05-12 09:38:55 -05:00
import { browser } from 'protractor'
async function browserSleep (amount: number) {
2020-08-26 07:38:34 -05:00
const oldValue = await browser.waitForAngularEnabled()
// iOS does not seem to work with protractor
// https://github.com/angular/protractor/issues/2840
if (await isIOS()) browser.waitForAngularEnabled(true)
2020-05-12 09:38:55 -05:00
await browser.sleep(amount)
2020-08-26 07:38:34 -05:00
if (await isIOS()) browser.waitForAngularEnabled(oldValue)
2020-05-12 09:38:55 -05:00
}
async function isMobileDevice () {
const caps = await browser.getCapabilities()
return caps.get('realMobile') === 'true' || caps.get('realMobile') === true
}
async function isSafari () {
const caps = await browser.getCapabilities()
return caps.get('browserName') && caps.get('browserName').toLowerCase() === 'safari'
}
async function isIOS () {
return await isMobileDevice() && await isSafari()
}
export {
isMobileDevice,
isSafari,
isIOS,
browserSleep
}