-1

I'm facing problems when interacting with dynamic pages i.e. it's static content becomes invalid after time. Normally, I save the page object when going to the page for the first time:

to StartPage
def startPage = at StartPage

When accessing the page object at later time the static content might became invalid. I guess that Geb is building the page's DOM tree when I'm going to the page for the first time. Am I right?!

How can I trigger a refresh of the DOM tree so that the static content will be overwritten?

AndyDoe
  • 31
  • 1
  • 6
  • What do you mean by "static content might become invalid"? Geb doesn't build any DOM tree, it always looks at current state of the DOM when you execute selectors/access page object content. What exactly is the problem you're having? – erdi Jun 02 '14 at 21:59
  • I mean that variables I've defined within the static content closure cannot be used at a later time within page methods, e.g. static content = { inputUserName { $("input", id: "username") } } --> Methode usage: waitFor { inputUserName.isDisplayed() } Sometimes, I'm facing an Geb waiting time out. – AndyDoe Jun 03 '14 at 08:31
  • It simply means that these elements are not there when you are trying to access them. No amount of "refreshing" would help if something isn't there in the first place. And no "refreshing" is necessary as it always executes the selector whenever you call it. – erdi Jun 03 '14 at 11:53
  • The fact that you define page/module content in a static content closure is just an implementation detail. Content element are not "compiled" or "parsed" or whatever at any particular time. The content is being built/created every single time you request it (e.g. `browser.page.myModule.myElement`). It would probably be easier to investigate what your problem really is if you posted some code that would allow the discussion to be less general. – erdi Jun 04 '14 at 12:50
  • Thanks so far, erdi! I will send the code snippet as soon as such an error occures again. – AndyDoe Jun 06 '14 at 07:21

2 Answers2

0

Here comes some code snippet which caused the problem above:

PkPortalWizardInitialPagePopup:

static at = {
    waitFor { inputStartAssistant.displayed }
}

static content = {
    inputStartAssistant { $("input#BtnNext", nicetitle: "Assistent starten") }
}

def cancelAssistant() {
    waitForWithSleep { buttonCancel.enabled }
    buttonCancel.click()
}

def submitCancellingAssistant() {
    waitForWithSleep { buttonSubmit.enabled }
    buttonSubmit.click()
}

PkPortalEpbListPage:

static at = {
    waitFor { inboxLink.isDisplayed() }
}

static content = {
    inboxLink { $("a.ctxLink", text: "Posteingang") }
}

Test code:

    def portalAssistant = at PkPortalWizardInitialPagePopup
    portalAssistant.cancelAssistant()
    portalAssistant.submitCancellingAssistant()
    def portalEpostLetterListPage = at PkPortalEpbListPage --> ERROR

Error: geb.waiting.WaitTimeoutException: condition did not pass in 60.0 seconds (failed with exception)

The cancellation of the login wizard popup directs the user to the PkPortalEpbListPage but the at checker caused the error above.

AndyDoe
  • 31
  • 1
  • 6
0

A minor modification of the Geb navigator could solve the problem:

inboxLink { $("a.ctxLink", text: contains("Posteingang")) }

Don't know really why since the text does not contain any spaces. Geb magic?

AndyDoe
  • 31
  • 1
  • 6