While developing Geb script in IntelliJ it's very hard to navigate to page object method, So every time it required to open that page and serach for method.
For example:
Class LoginPage extends Page {
static at = { waitFor("slow") { title == "Login Page" }}
static content = {
txtUsername {$("#txtUserName")}
txtPassword {$("#pwd")}
btnLogin (required:false) {$("#Login")}
}
def login(String userName, String pwd){
// ...
}
}
class LoginSpec extends GebSpec {
def "verify logic scenario" {
given: 'Username and Password'
def username = "abc"
def password = "jdaafafjadfgajffaghfg"
when: 'Fire Login URL'
to LoginPage
and: 'Enter Valid username,password and click on Login button'
login(username, password)
then: 'It should successfully and redirect to homepage'
at HomePage
}
// ...
}
Here it's not easy to navigate to login method with one click.
Do we have any plugin or setting to make easy this navigation?
You can place the cursor on the page class name and just press Ctrl-B
or use Ctrl-LeftMouse
in order to get there. As for easier navigation and code completion, I suggest assigning the result of to MyPage
to a variable and then use that variable for calling page methods, e.g.
class LoginSpec extends GebSpec {
def "verify logic scenario" {
given: "user name and password"
def username = "abc"
def password = "jdaafafjadfgajffaghfg"
when: "opening login page"
def loginPage = to LoginPage
and: "logging it with valid credentials"
loginPage.login(username, password)
then: "after successful login the user gets redirected to the homepage"
at HomePage
}
}
Now Ctrl-B
and Ctrl-LeftMouse
should also work for your method calls and page element references such as loginPage.txtUsername
.