The webpage I'm testing has an index page, which is the first page the user lands-on, after signing in.
I wish to set Index as an initial page for multiple test methods, so that:
- tests can refer to that initial page
- tests don't have to explicitly navigate to that page at the start of the test.
So, I tried pulling this impl to a base class:
class MyPage extends Page {//...}
class Index extends MyPage {//...}
class MySpec extends GebReportingSpec {
@Shared
Index index
def setupSpec() {
to LoginPage
login username, password
}
def setup() {
index = at Index // begin each test method at Index
}
}
class FooSpec extends MySpec {
def test1() {
//assume we're at Index, pointed-to by index
// test..
}
def test1() {
//assume we're at Index, pointed-to by index
// test..
}
}
But...
* When MySpec.setup() calls 'at Index',on test1 is successful (as LoginPage.login() will land it on Index), but test2 fails, because test1 doesn't finish at Index.
* If I set MySpec.setup() to call 'to Index', test1 hangs until the test fails, only loading parts of the Index page (and thus failing Index's at() check).
When test1 & test2 call 'at Index'/'to Index' respectively, all's well.
How can I fix my Base spec?
Thanks!