"from behave import *" 不允许我使用 given when then 等来定义步骤
"from behave import *" is not allowing me to use given when then etc to define steps
from behave import *
import time
DEFAULT_EMAIL = ""
DEFAULT_PASSWORD = ""
@given("unauthenticated user loads the home page")
def step_impl(context):
assert context.is_sign_in_submit_displayed()
@step("sign-in button is clicked")
def step_impl(context):
context.login_page = context.login.click_sign_in_submit()
@when("login form is populated with valid credentials")
def step_impl(context):
context.enter_email(DEFAULT_EMAIL)
context.enter_password(DEFAULT_PASSWORD)
@then("login is successful")
def step_impl(context):
assert context.home_page.is_rewards_displayed()
assert context.home_page.is_account_displayed()
行为导入是否未定义给定时间等?到目前为止,我仅从此片段中看到以下错误:
{
Undefined variable 'given'
Undefined variable 'step'
Undefined variable 'when'
Undefined variable 'then'
}
通过使用 pip3 而不是 pip 安装解决了这个问题。
from behave import *
import time
DEFAULT_EMAIL = ""
DEFAULT_PASSWORD = ""
@given("unauthenticated user loads the home page")
def step_impl(context):
assert context.is_sign_in_submit_displayed()
@step("sign-in button is clicked")
def step_impl(context):
context.login_page = context.login.click_sign_in_submit()
@when("login form is populated with valid credentials")
def step_impl(context):
context.enter_email(DEFAULT_EMAIL)
context.enter_password(DEFAULT_PASSWORD)
@then("login is successful")
def step_impl(context):
assert context.home_page.is_rewards_displayed()
assert context.home_page.is_account_displayed()
行为导入是否未定义给定时间等?到目前为止,我仅从此片段中看到以下错误:
{
Undefined variable 'given'
Undefined variable 'step'
Undefined variable 'when'
Undefined variable 'then'
}
通过使用 pip3 而不是 pip 安装解决了这个问题。