How do I check if Geb Module "content" is present?

Viewed 8860

I'm a bit new to the whole Selenium/Geb thing, so I'm probably going about this a bit wrong, but I'm trying to get the exists() method in the following code to work properly.

class Question extends Module {
    static base = { $("fieldset") }
    static content = {
        input { $("input[type=text]") }
        name { input.getAttribute("name").toString() }
    }
    boolean exists() {
        return input.isPresent()
    }

Frustratingly, when I try to execute that code (from a Spock Test, "go"ing to a PageObjectm including this module, I get the following:

The required page content 'input - SimplePageContent (owner: question - Question (owner: MyPage, args: [], value: null), args: [], value: null)' is not present

I've tried a number of other things, including:

  • if (input) return true; return false,
  • ... input.size() == 0,
  • Using static at = {...} (doesn't seem to be supported for modules"

Any ideas

1 Answers
Related