gpt4 book ai didi

robotframework - 如何在 Robot Framework 中运行小 cucumber 风格的测试用例

转载 作者:行者123 更新时间:2023-12-03 16:29:04 25 4
gpt4 key购买 nike

是否必须执行一些配置设置才能让 Robot Framework (RF) 运行 Gherkin/BDD 风格的测试用例?

我已经在 Windows 7 上安装了 RF 2.8.3,并且在 Selenium2Library 和 DatabaseLibrary 上运行正常。根据用户文档和网络上的其他信息,我应该能够编写和运行 Gherkin 风格的测试。但是,当我这样做时,我会出错。在尝试匹配关键字之前,RF 不会剥离 Gherkin 关键字(Given、When、Then、...):

Tests.Group001 GeneralTests
==============================================================================
Scenario: No template operation selected | FAIL |
No keyword with name 'But page does not contain a no template operation selected error message' found.
------------------------------------------------------------------------------

我使用直截了当的方式运行测试:
pybot ../Tests

我的示例测试文件是:
*** settings ***

Library Selenium2Library
Library DatabaseLibrary
Library kw_common

*** Test Cases ***

Scenario: No template operation selected
Given I have logged in and I have selected to perform template configuration
When I do not select a template operation
But page does not contain a no template operation selected error message
And I press the next button
Then I should not see a template operation selected error message


*** Keywords ***

I have logged in and I have selected to perform template configuration
Log Given I have logged in and I have selected to perform template configuration

I do not select a template operation
Log No template operation selected

page does not contain a no template operation selected error message
Page Should Not Contain 'ddTemplateOperation' is required.

I press the next button
Click Element xpath=//input[contains(@id,'next')]

I should not see a template operation selected error message
Page Should Contain 'ddTemplateOperation' is required.

帮助将不胜感激。谢谢。

最佳答案

来自官方文档 http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#ignoring-given-when-then-and-but-prefixes :

Prefixes Given, When, Then and And are dropped when matching keywords are searched



所以 page does not contain a no template operation selected error message关键字需要重命名为 But page does not contain a no template operation selected error message .

关于robotframework - 如何在 Robot Framework 中运行小 cucumber 风格的测试用例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21260931/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com