Как взять screenShot в огуречном огурце, используя в качестве основы завесу? - PullRequest
1 голос
/ 12 июня 2019

Я пытаюсь сделать снимок экрана после неудачного шага:

const { After } = require('cucumber');

After(function (scenario) {
    if (scenario.result.status ==='failed') {
        var world = this;
        return browser.takeScreenshot().then(function(screenShot, error) {
            if (!error) {
                world.attach(screenShot, "image/png");
            }
        });
    }
  });

В браузере отображается ошибка: ReferenceError: браузер не определен

1 Ответ

1 голос
/ 13 июня 2019

Попробуйте ниже. Удостоверьтесь, что имя веб-драйвера совпадает с вашим именем.

var {After, Status} = require('cucumber');

After(function (testCase) {
  var world = this;
  if (testCase.result.status === Status.FAILED) {
    // driver- update this with the correct webDriver variable
    return driver.takeScreenshot().then(function(screenShot) {
      // screenShot is a base-64 encoded PNG
      world.attach(screenShot, 'image/png');
    });
  }
});
...