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}
Related
Through Katalon studio UI tool we are able to perform parallel execution of test suites in test suite collection for different browsers.
Problem: Same approach is not working when we tried through cmd. Below is the command for the same:
katalon -noSplash -runMode=console -projectPath="<projectPath>" -retry=0 -testSuitePath="<testSuitePath>" -executionProfile="default" -browserType="Chrome,IE"
Note: Works fine for single browser as parameter
Please let us know if above command is correct for multiple browser execution
Expected :
Single report folder containing parallel execution results of both the browsers
You can do that, by using Test Suite Collections.
You put your TC1 (test case) in TS1 (test suite). My test case is called "proba" in this example. Then you create a TSC1 (test suite collection) and you add the same test suite twice to the collection. See screenshot. And change "Run with" parameter to Chrome and IE, respectively.
If you now create a command line argument, you will get something like
katalon -noSplash -runMode=console -consoleLog -projectPath="C:\\Katalon Studio\PROJECT NAME\PROJECT NAME.prj" -retry=0 -testSuiteCollectionPath="Test Suites/TEST SUITE COLLECTION 1"
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.
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
In a test case I am able to read a csv file by following code
${value} = read_csv_file TestData.csv
Set Test Variable ${value}
log ${value}
But now the question comes why my test case will repeat for different data. Although if I want to repeat any step I can use for loop but I want to repeat this for entire test suite.
:FOR ${newvalue} in #{value}
\ Select Product #{newvalue}[0]
Templates are not preferred because they make the framework totally data-driven and also they have certain limitation.
As you don't want to use templates, you can also use keyword-driven approach of robot framework.
You need to create a robot resource file, define your keyword and call it where you want this particular code in your robot test suite.
***keywords***
Read and display
[Argument] ${filename}
${value} = read_csv_file ${filename}
Set Test Variable ${value}
log ${value}
Is it possible to initialize a variable in a suite or test setup based on the return value of a keyword? I've tried this sort of syntax and it didn't work:
*** Settings ***
| Suite Setup | ${A variable}= | Set Variable | A String
I know I can call keywords like "Set Suite Variable" but they don't allow me to set the variable to the result of another keyword. I used "Set Variable" in this example, but I want to be able to call any keyword here.
Strictly speaking, no, it's not possible. Within a suite or test setup you can only call keywords, you cannot set variables to the result of other keywords directly within the setup statement .
That being said, it's easy to create a custom setup keyword that does what you want. For example:
*** Settings ***
| Suite Setup | Custom suite setup
*** Keywords ***
| Custom suite setup
| | ${A Variable}= | Set Variable | A String
| | Set suite variable | ${A Variable}
The above has the same effect as if robot supported setting variable from keywords directly in the setup. And, of course, you can call any keyword, not just Set Variable.
To expand on Bryan's answer and add clarification for those of you not specifically interested in creating a suite variable based on the results of a keyword, there are other ways to initialize "global" variables at the start of a Robot Framework test.
The easiest way is to put them under a Variables header.
*** Variables ***
${this_string} This String
${that_int} 5
An alternative way to do that is to put the same variables in a Resource .txt file. Once it's called under *** Settings ***, the variables can be used freely. Assuming you have your variables in a file called VarList.txt, the following code will initialize them:
*** Settings ***
Resource VarList.txt
Should you be using a Resource file with existing keywords and internal variables, this will also work for that.
This all assumes you want static variables. Set Suite Variable and Set Global Variable can both be used with keywords like Bryan said. Set Suite Variable works well for scripts with multiple test Suites, while Set Global Variable should be used extra sparingly in that case. In a single-Suite script, however, the differences are all but negligible, though best practice would be to stick with Set Suite Variable unless you really want it to be global, just on the off-chance you decide to add that Suite to a script running multiple Suites.