Monday, February 3, 2014

No such property error in Cucumber specs with Geb

It is common to write Geb specs directly referencing page elements like:
  to LoginPage
  loginField << login
  passwordField << password
  loginButton.click()

But if you try doing same with Cucumber step files, you will get exception, like:
No such property: loginField for class: steps.Login_steps
groovy.lang.MissingPropertyException: No such property: loginField for class: steps.Login_steps
 at steps.Login_steps$_run_closure2.doCall(Login_steps.groovy:42)
 at ✽.When user enters login and password(Login.feature:7)

This is because page object is not bound and you should reference it explicitly, like:
  to LoginPage
  page.loginField << login
  page.passwordField << password
  page.loginButton.click()


No comments:

Post a Comment