首页 > 解决方案 > 如何处理 Behave 中的常见步骤

问题描述

我有 4 个功能文件,例如登录、添加到购物车、按产品搜索、运输方式计算。所有 4 个都是单独的功能文件,前 4 个步骤完全相同,如下所示:

Given I go to website
When I click on the login button
Then I enter username and password
And I verify I am logged in successfully

如果我在所有功能文件中使用相同的步骤,它就不起作用。它有一个不明确的步骤错误。

我的目标是首先登录所有 4 个功能文件,然后进入下一个相应步骤。

我面临的错误:

raise AmbiguousStep(message % (new_step, existing_step))
behave.step_registry.AmbiguousStep: @given('I am loggedin into website') has already been defined in
  existing step @given('I am loggedin into website') at features/steps/Steps_cart.py:5

标签: python-behave

解决方案


推荐阅读