testing - How to pass arguments to content definitions in Geb? -
i have page (startpage) links several books , i'd create generic method or content definition clicks on link specific title , navigate page. book pages have static string title
defined defines book's title. want (startpage):
def <t extends page> t openbook(class<t> pagetype) { $(".product h3", text: pagetype.title).parents("a").click() browser.to(pagetype) browser.page t }
however doesn't work since when navigate pagetype
(using browser.to(pagetype)
) seems geb redirects me login page instead of requested pagetype
(maybe because when phone call to
session reset?).
if refactor method , hardcode content definition:
static content = { openmybook(to: mybookpage) { $(".product h3", text: "my book title").parents("a")} }
it works calling openmybook
can see book page (mybookpage
) , text
hardcoded.
so question if can pass arguments content definition (openmybook
) or modify openbook
method navigate book page without lossing session.
you need utilize browser.page(pagetype)
here instead of to()
because to()
drives browser url of page type passed in. didn't specify static url = '...'
field these pages , default root of base of operations url why you're seeing browser end @ login page.
it improve if used browser.at(pagetype)
here because @ checker book pages verified , at()
sets page on browser after successful verification.
testing groovy geb
No comments:
Post a Comment