If you could include the block of code that actually uses the navLinkPage1
link, I believe we could track down your exact issue with navLinkPage1
, but it sounds like your block of code is going "to MyPage
" instead of "to HomePage
".
That said, consider the Module Object pattern over the Page Object pattern for complex UIs (disclaimer: I just made that term up). So, instead of making every page inherit from MyPage
, creating a (false?) relationship between the Page
s, make, say, a "NavigationModule
", a la:
class NavigationModule extends Module {
static content = {
homeLink { $("a", title:"Home") }
contactLink { $("a", title:"Contact Us") }
}
}
class HomePage extends Page {
static content = { navBar { module NavigationModule } }
}
and in your test, you'd say:
to HomePage
navBar.contactLink.click()
Personally, I've been treating modules like classes, and pretended their content is private, only giving myself access to operations rather than content. So, only accessing my LoginModule
via the logIn(user,pass)
method, rather than interacting directly with the username
and password
members... but... that may not work for you. A nav bar is particularly well suited to direct access. :-)