aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/e2e/src/utils.ts
blob: a9d30c03acdc7ff8632aa7aa9bf7e6a553617b1a (plain) (blame)
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
28
29
30
31
32
33
34
import { browser } from 'protractor'

async function browserSleep (amount: number) {
  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)

  await browser.sleep(amount)

  if (await isIOS()) browser.waitForAngularEnabled(oldValue)
}

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
}