Search code examples
intellij-ideageb

Geb Modules showing an error


I'm working on a geb page object with a repeating set of UI elements a div container with a text input and button within.

I am attempting the following:

class MyModule extends Module{
  static content = {
    textInput {$("input.editTextField")}
    removeInputButton {$("button.removeButton")}
  }
}

class MyPage extends Page{
  static content = {
    myInputs { index ->
      $("div.container", index).module(MyModule)
    }
}

In IntelliJ the code is highlighted in MyPage on ("div.container, index) when I hover over this I see "'$' in 'geb.Page' cannot be applied to '(java.lang.String.?)'

My goal is to be able pick an iteration of the UI and to perform something like:

myInputs(0).textInput = 'foo'
myInputs(1).textInput = 'bar'
myInputs(5).removeInputButton.click()

I've referred to the documentation for Geb but by all accounts this should work. Any help would be appreciated.


Solution

  • This will work, it's just that your code is not type safe enough for IntelliJ to know which method you're calling. If you change your content definition to:

    myInputs { int index ->
        $("div.container", index).module(MyModule)
    }
    

    then the warning will disappear.