I have same simple testcase, I want to use this testcases as keywords. For example:
*** Test Cases ***
User Can Add Iteam To Bucket
same keywords
User Can Perform Checkout Bucket
User Can Add Iteam To Bucket
User Can do samething else
You cannot run a test case from another test case.
The solution is to make User Can Add Iteam To Bucket into a keyword that you can call from multiple places.
Related
I am trying to give more than one instruction after a "Run Keyword If" method, but the syntax allows me to give just one? How i can give multiple instructions after condition executed as true?
If you want an easy to read solution you could create another keyword with all your other actions inside of it. For example.
run keyword if '${a}'=='${a}' my keyword
my keyword
[Documentation] This is documentation
Action A
Action B
You can use the keyword Run Keywords with AND connector. Example given below:
Run Keyword If '${TEST1}'=='${TEST2}' Run Keywords Keyword1 AND Keyword2
I'd like to have the option to run my tests with different test data depending on the environment I'm in, as they are slightly different.
My current setup: Test suite -> Test Cases each with 1 test data (excel file). I run checks (based off execution profile) to determine the environment and adjust the domain URL accordingly.
If I add a second data file to a test case, is there a way I can add logic to pick a specific test data file during execution time?
If you want to use "excel_file_1" for "default" execution profile, and "excel_file_2" for other execution profiles, use this:
import com.kms.katalon.core.configuration.RunConfiguration as RC
import com.kms.katalon.core.testdata.TestDataFactory as TestDataFactory
if (RC.getExecutionProfile()=='default'){
def data = TestDataFactory.findTestData("excel_file_1")
} else {
def data = TestDataFactory.findTestData("excel_file_2")
}
Just for clarity, I will explain most of the process to accomplish this.
You could create different profiles for this (Generally used for environment variables).
Katalon Profiles
You may then enter keywords (which are GlobalVariables) to get or set
your data (URLs, locations, etc.)
Remember to add your test case(s) in a test suite
You may then create separate build commands to test each profile you
created by clicking Build CMD & specifying the execution profile
Specify profile in Build CMD
This way you can use something like TeamCity to run each cases or a combination thereof
I don't think this works as Katalon have more that one Test Case in test suite
import com.kms.katalon.core.configuration.RunConfiguration as RC
import com.kms.katalon.core.testdata.TestDataFactory as TestDataFactory
if (RC.getExecutionProfile()=='default'){
def data = TestDataFactory.findTestData("excel_file_1")
} else {
def data = TestDataFactory.findTestData("excel_file_2")
}
In above code below question comes
whats 'data' variable
what if we have few more test cases and that too have data sheet
I wrote my First Gherkin Script (first.robot) when running same i am getting "No keyword with name 'Given' found." Error. Is there any Library i have to include or should i do any pip install something??
***
Gherkin Style TC
[Documentation] Let me try this time
Given Environement Setup Ready
When Required URL Get Loaded
Then Wait For Meters List to Appear
And Capture the list of Meters
Then CloseBrowser
***
You have two spaces after Given (and the others) but robot uses two spaces to separate keywords from arguments. You must have only one space after Given, When, etc. otherwise robot will think that Given is a keyword.
Gherkin Style TC
[Documentation] Let me try this time
Given Environement Setup Ready
When Required URL Get Loaded
Then Wait For Meters List to Appear
And Capture the list of Meters
Then CloseBrowser
Some people add extra space before the given/when/then to make things line up nicely:
Gherkin Style TC
[Documentation] Let me try this time
Given Environement Setup Ready
When Required URL Get Loaded
Then Wait For Meters List to Appear
And Capture the list of Meters
Then CloseBrowser
I'm currently developing a couple of test cases with robotframework to compare some excel value with value inside our database.
I have to do it inside a specific test case as it is deploy on zephyr.
I am checking each value inside this test case by calling a homemade Keyword that does :
Run Keyword Should Contain ${valeurExcel1} ${valeurBDD1}
Run Keyword Should Contain ${valeurExcel2} ${valeurBDD2}
etc...
I need every single one of those "Should Contain" to be display in a separated row in the report.html
It currently only appear as one row as it is one test case.
Is there anyway to specify to robot framework that i want him to consider every "Should Contain" as a unique test case and to display it in a row on the report.html ?
(Maybe by tagging ?)
No you can't. If you want a row for each "should contain" then each of those call should be made in its own test case.
But I think the problem lies in your "I have to do it inside a specific test case as it is deploy on zephyr". Whatever you need to do before/after a test case, can be done in a "suite setup" (and "suite teardown"). So you could have this kind of architecture:
*** Settings ***
Suite Setup deploy SUT / Zephyr
Suite Teardown shutdown SUT / Zephyr
*** Test Cases ***
tc1
Run Keyword Should Contain ${valeurExcel1} ${valeurBDD1}
tc2
Run Keyword Should Contain ${valeurExcel2} ${valeurBDD2}
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.
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.