Protractor: how to catch error or timeout on browser.driver.get(url) if remote url is fail to load?

902 views Asked by At

It seems when protractor execute "browser.driver.get(...)" it waits until page is loaded or throw "Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL" message. Remote url is 1 to 10 times fail to load (following by freeze). A workaround for that is to refresh/reload page. Is there any way to implement that behaviour in Protractor? (let say repeat action 4-8 times and then continue)

1

There are 1 answers

3
Andrew Eisenberg On

You should be able to catch errors thrown through the promises api, like this:

browser.driver.get(...).then(function(result) {
  // do something when page is found
}.thenCatch(function(error) {
  // do something with the error
});