0

Error:

TypeError: step_impl() missing 1 required positional argument: 'context'

Code:

@when('the user clicks on "Login"')
def step_impl(self,context):
    """
    :type context: behave.runner.Context
    """
    homePage.loginButton(self)
Andrei Suvorkov
  • 5,559
  • 5
  • 22
  • 48
Vibha
  • 31
  • 6
  • 1
    You are trying to invoke `step_impl()` without arguments, it need to get `context` parameter. – Guy Aug 09 '18 at 06:28
  • @Guy I think there is more to that question, it seems like the OP has created `class` and in that case `self` will be the first parameter. The question is how to add steps in `class` in `behave` – Vishrant Feb 05 '22 at 02:44
  • https://github.com/behave/behave/issues/630 Here is the discussion about this – Vishrant Feb 05 '22 at 02:47

1 Answers1

0

The first argument for the step_impl function is context, not self, hence your error. If you're interested, you can learn a little about positional and keyword arguments here.

That is,

@when('the user clicks on "Login"')
def step_impl(context):
    """
    :type context: behave.runner.Context
    """
    homePage.loginButton(self) # This line of code will break
natn2323
  • 1,983
  • 1
  • 13
  • 30