Is there some configuration setting that I must perform to get Robot Framework (RF) to run Gherkin/BDD style test cases?
I have installed RF 2.8.3 on Windows 7 and is running OK with Selenium2Library and DatabaseLibrary. According to the user docs and other info on the web, I should be able to write and run Gherkin style tests. However, when I do this, I get errors. RF does not strip the Gherkin keywords (Given, When, Then, ...) before trying to match the keyword:
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.
------------------------------------------------------------------------------
I run the tests using a straight-forward:
pybot ../Tests
My sample test file is:
*** 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.
Help would be much appreciated. Thanks.
To create Gherkin test scenarios suitable for both manual and automated execution, turn on the Automation ready (BDD mode) setting of your test project. This will command the test editor interpret the Gherkin keywords appropriately and automatically create action words (reusable steps) from them.
Executing Your Selenium Tests in the Robot Framework To execute robot tests in your prompt, type: robot path/to/tests. 'path/to/tests' should be a name of a suite file or a suite directory.
Robot Framework is a Test driven development framework. You can utilize it by a keyword driven approach or a more BDD approach using a Gherkin style test.
From the official documentation 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
So page does not contain a no template operation selected error message
keyword needs to be renamed to But page does not contain a no template operation selected error message
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With