Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading of different URLs w/ PageObjects fails #1034

Closed
davidlinse opened this issue Jun 21, 2016 · 2 comments
Closed

Loading of different URLs w/ PageObjects fails #1034

davidlinse opened this issue Jun 21, 2016 · 2 comments

Comments

@davidlinse
Copy link
Contributor

I think there might be an unexpected behavior when one attempts to load different URLs with a Page-Object. Please see the following two examples.

module.exports = {
  after: function(browser) {
    browser.end();
  },

  // works as expected
  'Attempt to load multiple pages with browser': '' + function(browser) {

    browser
      .url('http://nightwatchjs.org')
      .waitForElementPresent('body', 10000)
      .assert.urlContains('nightwatchjs.org')

      .url('http://golem.de')
      .waitForElementPresent('body', 10000)
      .assert.urlContains('golem.de')

      .url('http://github.com')
      .waitForElementPresent('body', 10000)
      .assert.urlContains('github.com');
  },

// fails gracefully
'Attempt to load multiple pages w/ page objects': function(browser) {

    var page = browser.page.Google();

    page
      .navigate()  // http://google.com set as url property in page-object
      .waitForElementPresent('body', 10000)
      .assert.urlContains('google.com')
      .api.perform(function() {
        page.url = function() { return 'http://nightwatchjs.org'; };
      });

    page
      .navigate()
      .waitForElementPresent('body', 10000)
      .assert.urlContains('nightwatchjs.org')

      .api.perform(function() {
        page.url = 'http://github.com';
      })
      .waitForElementPresent('body', 10000)
      .assert.urlContains('github.com');
  }
};

I could not find a way to update the url property of a page-object.
@beatfactor maybe you can shed some light ?

regards
~david

@RickEyre
Copy link

I'm having this same issue with dynamic URLs.

@senocular
Copy link
Contributor

The way its implemented now is that urls are evaluated at page object creation, not at time of navigate. Re-defining the value of url in the middle of the test will not alter the outcome of the url and will instead fail due to the fact that the value of url at that point is expected to be a string (resolved from string or function on creation) rather than a function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants