python-behave - 如何处理 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
解决方案
推荐阅读
- java - java中的随机唯一字母数字字符串
- javascript - 如何在MongoDB中执行updateMany时使用外部值和字段内的值执行乘法运算
- javascript - 删除帖子时出现“posts.map 不是函数”错误
- ios - swift - 将 JSON 数据保存到本地文件
- c# - 在 Xamarin Forms 中更改背景颜色的有限时间
- html - 与其他浏览器不同,为什么 Firefox 以隐藏另一个页脚的方式显示底部粘性页脚?
- wpf - 如何在 WPF 应用程序中以编程方式显示 Emgu CV 图像框
- excel - Power Query 将表中的一列映射到另一表的三列
- c# - 从多个列表中选择
- c++ - 从 field_buffer 返回的 char* 指向的缓冲区大小