I am attempting to reference a module from inside another module and it is not working as expected. I am not sure where I have gone wrong so I will let my code example/stack trace do the talking.
Main Test Spec:
class TestSpec extends GebReportingSpec {
//bunch of code yada yada
def "someFeatureMethod"(){
at Page1
module1.doThing()
}
}
Here is what Page1 looks like:
class Page1 extends Page {
static content = {
module1 { module(new Module1())}
}
}
Here is what Module1 looks like:
class Module1 extends Module{
static content = {
module2 {module(new Module2())} //not going to type it out but assume module2 has a method named someFunction2()
}
def doThing(){
//This is where I am unsure the most. I have tried a few different things in this section
browser.at Page1
module1.module2.someFunction2()
}
}
My stack trace is something like this:
groovy.lang.MissingPropertyException: Unable to resolve module1 as content for Page1 -> module1: Module1, or as a property on its Navigator context. Is module1 a class you forgot to import?
I did import everything I possibly could.
All I want is to be able to have a module inside a module if this is possible, please explain how it is implemented thank you.
The proper syntax in the doThing() method is as follows:
def doThing(){
module2.someFunction2()
}
I actually had a type-o when I tried this earlier which is why I was so confused. after fixing the type-o I tested and this setup works.