steps_file.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* global performActionBegin performActionEnd */
  2. // in this file you can append custom step methods to 'I' object
  3. module.exports = () =>
  4. actor({
  5. // Define custom steps here, use 'this' to access default methods of I.
  6. // It is recommended to place a general 'login' function here.
  7. _performActionBegin(name) {
  8. return performActionBegin(name);
  9. },
  10. _performActionEnd(name) {
  11. return performActionEnd(name);
  12. },
  13. /**
  14. * Group steps to one action for statistics
  15. * @param {string} name - Name of action
  16. * @param {function} actions - What to do
  17. */
  18. async performAction(name, action) {
  19. this.say(name);
  20. this._performActionBegin(name);
  21. await action();
  22. this._performActionEnd(name);
  23. },
  24. waitTicks(n) {
  25. return this.executeScript((ticks) => {
  26. return new Promise((resolve) => {
  27. let count = 0;
  28. const tick = () => {
  29. count++;
  30. if (count >= ticks) {
  31. resolve();
  32. } else {
  33. requestAnimationFrame(tick);
  34. }
  35. };
  36. requestAnimationFrame(tick);
  37. });
  38. }, n);
  39. },
  40. });