lundi 25 juillet 2016

Protractor - properly handling the errors...

I've tried to put the descriptive error message and exit the test run via fail() function but only with a partial success - it appears that I am doing something wrong... Here is my code:

it('set up internal budget', function(done) {
    var acceptBudgetButton = element(by.buttonText('Accept Budget'));
    page.setInternalBudget();  //setting budget values

    browser.wait(function() {
      return browser.isElementPresent(acceptBudgetButton);
    }, 30000, 'Error - Accept Budget button is not visible.');
    acceptBudgetButton.click();
    done();
    done.fail('Unable to setup internal budget. Terminating test run');
  });

When "Accept Budget" button is not available I expected 3 things from this script:

1) See "Accept Budget button is not visible" error, followed by wait time out

2) See "Unable to setup internal budget. Terminating test run" error

3) Expect protractor to immediately exist test run, as we got into failure.

In the reality, only first expectation is met. Script keeps on running and I don't even get "Unable to setup internal budget" error... so it looks like my done.fail statement is being ignored.

What should I change to make all of my dreams/expectations come true?

Aucun commentaire:

Enregistrer un commentaire