Bin
2025-12-17 1442f92732d7c5311a627a7ba3aaa0bb8ffc539f
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
35
36
37
38
39
40
41
42
/* global  performActionBegin performActionEnd */
// in this file you can append custom step methods to 'I' object
 
module.exports = () =>
  actor({
    // Define custom steps here, use 'this' to access default methods of I.
    // It is recommended to place a general 'login' function here.
    _performActionBegin(name) {
      return performActionBegin(name);
    },
    _performActionEnd(name) {
      return performActionEnd(name);
    },
    /**
     * Group steps to one action for statistics
     * @param {string} name - Name of action
     * @param {function} actions - What to do
     */
    async performAction(name, action) {
      this.say(name);
      this._performActionBegin(name);
      await action();
      this._performActionEnd(name);
    },
 
    waitTicks(n) {
      return this.executeScript((ticks) => {
        return new Promise((resolve) => {
          let count = 0;
          const tick = () => {
            count++;
            if (count >= ticks) {
              resolve();
            } else {
              requestAnimationFrame(tick);
            }
          };
          requestAnimationFrame(tick);
        });
      }, n);
    },
  });