stuplum/astrolabe

Explicit waits in page objects

Opened this issue · 0 comments

How would you perform an explicit wait inside your page object, the example would be to create a login function in the page object which would do all of the following:

ptor.driver.findElement(protractor.By.id('username')).sendKeys('Jane');
ptor.driver.findElement(protractor.By.id('password')).sendKeys('1234');
ptor.driver.findElement(protractor.By.id('clickme')).click();

// Login takes some time, so wait until it's done.
// For the test app's login, we know it's done when it redirects to
// index.html.
ptor.wait(function() {
  return ptor.driver.getCurrentUrl().then(function(url) {
    return /index/.test(url);
  });
});