all repos — caroster @ ae51e12252fdd1de29ad1ab9e32b48b893b7e2e8

[Octree] Group carpool to your event https://caroster.io

e2e/test/pages/_page.js (view raw)

 1/* eslint-disable class-methods-use-this */
 2'use strict';
 3import {cast} from './utils/cast';
 4export class Page {
 5  constructor(path) {
 6    this._path = path;
 7  }
 8
 9  get name() {
10    return 'undefined';
11  }
12
13  /**
14   * @return {string}
15   */
16  get path() {
17    return this._path;
18  }
19
20  /**
21   * @param {string} path
22   */
23  set path(path) {
24    this._path = path;
25  }
26
27  async open() {
28    console.log('browse url', this.path);
29    await browser.url(this.path);
30    await this.waitForDisplayed();
31  }
32
33  /**
34   *
35   * @param {string} selector
36   */
37  field(selector) {
38    throw new Error('Not implemented for ' + selector);
39  }
40
41  async submit() {
42    const field = this.field('submit');
43    const element = await $(field);
44    await browser.saveScreenshotByName(`${this.name}--filled`);
45    await element.click();
46  }
47
48  /**
49   *
50   * @param {string} selector
51   * @param {string} value
52   * @return {Promise<void>}
53   */
54  async type(selector, value = undefined) {
55    const field = this.field(selector);
56    if (typeof value === 'undefined') value = selector;
57    const element = await $(field);
58    await element.addValue(cast(value));
59  }
60
61  /**
62   *
63   * @param {string} selector
64   * @return {Promise<void>}
65   */
66  async click(selector) {
67    const field = this.field(selector);
68    await $(field).waitForDisplayed();
69    const element = await $(field);
70    await element.click();
71  }
72
73  async waitForDisplayed() {
74    await new Promise(resolve => {
75      setTimeout(resolve, 1200);
76    });
77    await browser.saveScreenshotByName(this.name);
78  }
79}