2

From time to time I'm using "Expected Conditions" feature introduced in protractor 1.7.

Use case:

var EC = protractor.ExpectedConditions;
browser.wait(EC.visibilityOf(header.displayName), 10000);

where header is a Page Object.

If header.displayName would not become visible in 10 seconds, an error would be thrown:

[firefox #4]   2) Describe description here
[firefox #4]    Message:
[firefox #4]      Error: Wait timed out after 10082ms
[firefox #4]    Stacktrace:
[firefox #4]      Error: Wait timed out after 10082ms
[firefox #4] ==== async task ====
[firefox #4]     at [object Object].<anonymous> (/Path/to/project/test/e2e/my.spec.js:38:17)

Which is not quite readable and require some time to understand and a bit of a research.

Question:

Is it possible to customize this kind of a wait timeout error?


FYI, we can provide custom expect failure messages as described here:

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195

1 Answers1

5

I believe browser.wait() takes 3 parameters: a condition, an optional timeout, and an optional description message. (I'm pretty sure this is the doc: http://angular.github.io/protractor/#/api?view=webdriver.WebDriver.prototype.wait, but I'm having a hard time verifying that the WebDriver shows up as browser in protractor). So you should be able to do:

var EC = protractor.ExpectedConditions;
var timeoutMS = 10 * 1000;
var timeoutMsg = "Waiting for header displayName";
browser.wait(EC.visibilityOf(header.displayName), timeoutMS, timeoutMsg);
P.T.
  • 24,557
  • 7
  • 64
  • 95