0

I'm fairly new to Protractor and E2E testing, but I've spent a few days researching, setting up page objects, and creating test suites, and one thing I'm wondering about is how to create good manual navigation between page objects and the actual pages.

Let's say I have some parts on my site that can navigate to other parts of it; the page object for one of them could look something like this:

var SomePartPage = function() {
    this.btnPopUp = // button for opening some pop up
    ...
    this.openPopUp = function() {
        this.btnPopUp.click();
        return popUpPage;
    };
};

I'm following the guideline that returning page objects is a good thing, and I'm assuming the promise returned by calling click() will be resolved before returning (as per WebDriverJS' control flow).

But I have a setup in my test where I want to verify that this navigation takes place correctly, and sometimes it works and sometimes it doesn't. So I'm assuming it's because my pop up isn't always fully loaded by the time I want to interact with it (i.e. by the time openPopUp() has returned).

Are my assumptions correct? And if so, how do I deal with this? I can use manual timers and promises of course, but I'd rather have some promise that gets resolved automatically when my pop up is fully loaded.

KasMA1990
  • 153
  • 1
  • 7
  • Is your pop-up a modal or a new browser window? If it is a new window you need to switch to that window with switchTo() https://code.google.com/p/selenium/source/browse/javascript/webdriver/webdriver.js#885 – Andres D Apr 16 '14 at 15:35
  • It's not a new window or tab, so that shouldn't be the issue. – KasMA1990 Apr 22 '14 at 06:07

1 Answers1

0

Actually I don't think the return will wait for the click();

I think you should do something similar:

browser.wait(this.btnPopUp.click(), timeout)
Lajos Veres
  • 13,595
  • 7
  • 43
  • 56
  • Waiting on the `click` doesn't make much sense, it just keeps clicking the button to open the pop up until the timer runs out. I tried waiting for elements on the pop up to appear (testing with `isPresent`), but that didn't work consistently either :/ – KasMA1990 Apr 23 '14 at 06:42