{"size": 948, "ext": "js", "max_stars_repo_path": "helpers/tapAtPointUntilNotVisible.js", "max_stars_repo_name": "tipsi/tipsi-prometheus", "max_stars_repo_stars_event_min_datetime": "2018-09-16T11:36:35.000Z", "max_stars_repo_stars_event_max_datetime": "2018-09-16T11:36:35.000Z", "max_issues_repo_path": "helpers/tapAtPointUntilNotVisible.js", "max_issues_repo_name": "tipsi/tipsi-prometheus", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "helpers/tapAtPointUntilNotVisible.js", "max_forks_repo_name": "tipsi/tipsi-prometheus", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.6, "max_line_length": 96, "alphanum_fraction": 0.6540084388}
/**
 * This helper tap on `coords` while `waitFor` element is hidden.
 * @param  {String}  coords            Object {x: INT, y: INT } with coords to tap
 * @param  {String}  waitFor           Element that need to be hidden
 * @param  {Number}  options.attempts  How many times to try before fail
 * @param  {Number}  options.timeout   Wait For Visibility timeout
 */
export default async function tapAtPointUntilNotVisible(coords, waitFor, props = {}) {
  const { attempts = 4, timeout = 10000 } = props

  try {
    await this.expectForVisible(waitFor, timeout)
    return
  } catch (e) {
    // Do nothing
  }

  try {
    await this.waitForVisible(waitFor, timeout, true)
    await this.touchPerform('tap', coords)
    await this.expectForVisible(waitFor, timeout)
  } catch (error) {
    if (attempts) {
      await this.tapAtPointUntilNotVisible(coords, waitFor, { attempts: attempts - 1, timeout })
    } else {
      throw error
    }
  }
}
