Using Nightwatch's Page Object capability, I have all the elements of a page defined as well as its URL. After navigating to the page (e.g., page.navigate()), the code waits for the one of the elements to be visible and then records the values of several elements before clicking on another element that leaves the page. I want to ensure that the page is no longer displayed by waiting for that same element to not be displayed, but that second wait always times out and I'm forced to look for an element that's not on that page to verify I've left the page. For example,
module.exports.command = function (settings) { var page = this.page.settings() page.navigate() .waitForElementVisible('@firstName',3000) .getValue('@firstName', function(r) {settings.firstName = r.value}) .getValue('@lastName', function(r) {settings.lastName = r.value}) .waitForElementVisible('@firstName',3000) .click('@dashboard') .waitForElementNotVisible('@firstName',3000) // this times out this.verify.visible('#AvailableProcedures') // but this works }
My question is: does a page object become invalid once the page is no longer displayed?