I'm struggling with the -s --suite option.
When I run my good all Test case files, like this: robot ., everything is fine (i.e. telling robot to run all test cases files in current folder, . for current folder). Or, if I want to run particular Test Case file, lets say robot mytest.robot, works fine too.
However, recently I have created an init file. That one is being executed when running robot . (because it is stored in that directory), but naturally not when running robot mytest.robot. So far everything is clear.
I thought the easy solution is to run robot -s mytest.robot .
However, I'm getting an error : Suite 'BDD' contains no tests in suite 'mytest.robot'.
Which is not right, because as I mentioned above, running it like robot mytest.robot from the very same directory works fine, the Test cases in that file are processed.
Moreover, I'm getting the same, even if I run robot -s non_existent_test_case_file.robot . >>> Suite 'BDD' contains no tests in suite 'non_existent_test_case_file.robot'., which should sort of also prove that the issue is not with my mytest.robot not having tests specified = the error message is simply wrong.
Using: Robot Framework 3.1 (Python 3.6.6 on linux)
Any hints ?
adding more info
I have created new folder "temp", where I moved my __init__.robot and mytest.robot files. I edited them so that they are as basic as possible.
__init__.robot:
*** Settings ***
Suite Setup RobotSetup
Suite Teardown RobotTeardown
*** Keywords ***
RobotSetup
Log To Console robot init setup
RobotTeardown
Log To Console robot init teardown
mytest.robot:
*** Test Cases ***
MyBestTestCase
Log To Console hello world
RESULTS:
[/vagrant/test/bdd/temp]$ ll
total 8
-rwxrwxrwx. 1 vagrant vagrant 213 Jan 23 10:44 __init__.robot
-rwxrwxrwx. 1 vagrant vagrant 74 Jan 23 10:44 mytest.robot
[/vagrant/test/bdd/temp]$ robot .
==============================================================================
Temp
==============================================================================
robot init setup
Temp.Mytest
==============================================================================
MyBestTestCase hello world
MyBestTestCase | PASS |
------------------------------------------------------------------------------
Temp.Mytest | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
robot init teardown
Temp | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
... AND
[/vagrant/test/bdd/temp]$ robot -s mytest.robot .
[ ERROR ] Suite 'Temp' contains no tests in suite 'mytest.robot'.
The problem is that you're telling robot to run the suite "robot" in the suite "mytest", and it can't find a suite named "robot". Since it can't find a suite named "robot", then it certainly can't find any tests in the suite named "robot".
When you use --suite, you do not give it filenames, you must give it test suite names. In your case you would run robot with robot -s mytest ..
Related
I am having trouble output/saving the results from my terminal commands.
*** Settings ***
Library Process
Suite Teardown Terminate All Processes kill=True
*** Test Cases ***
Example
Run Process adb devices -l
Current Output
Expected Output
However, if i just run adb devices -l, it will provide me with a list of android devices id.
E.g. List of devices attached
0429329319 device usb: xxxx
My attempts
Based on the robot framework, it has this example that i tried to follow but gave me errors such as "No keyword with name ${result} = Run Process found"
Sample code from robot framework
${result} = Run Process program stdout=${TEMPDIR}/stdout.txt stderr=${TEMPDIR}/stderr.txt
Log Many stdout: ${result.stdout} stderr: ${result.stderr}
Another way that i have discovered is to use 'Get Process Result' keyword.
So my question is - how do i print/save the output of my terminal commands?
Would appreciate if anyone can take a look at it
Referenced to
http://robotframework.org/robotframework/latest/libraries/Process.html
https://github.com/robotframework/robotframework/blob/master/atest/testdata/standard_libraries/process/get_process_result.robot
I just found out one way would be using the OperatingSystem library - 'Run'.
Then log the results of the command entered into the terminal/command prompt using 'Log To Console'
*** Settings ***
Library OperatingSystem
*** Test Cases ***
Get list of devices
${result} = Run adb devices -l
Log To Console [${result}]
To save the printed stuff in the console, just do
robot xx.robot > console.txt
Referenced to - how to run commands in CMD prompt using robot framework
I'm trying to invoke a shell scrip from within a .robot test case.
The .sh file is in the same folder as the .robot file
*** Settings ***
Library Process
*** Test cases ***
Run the shell script
Start Process ./getIDfromDB.sh shell=yes
I'm getting the error:
Setting variable 'Start Process ./getIDfromDB.sh' failed: Invalid variable name 'Start Process ./getIDfromDB.sh'.
Running on Ubuntu
Researched documentation for Robot framework but could not find a solution. Maybe digging in the wrong spot.
I'm not sure how you are trying to set the path of the shell script in the robot file. The error message seems to convey that something is wrong with the way you're initialising the variable to hold the path.
The following code should work:
*** Settings ***
Library Process
*** Variables ***
${pathToScript} ./getIDfromDB.sh
*** Test cases ***
Run shell script
${output} Run process ${pathToScript} shell=yes
The return code and the output displayed in the terminal are stored in the ${output} variable. You can access the details as ${output.rc} and ${output.stdout} respectively.
You can find more details about the result object here.
According error details the keyword is not recognized, I think, you need add extra spaces after keyword name:
Start Process ./getIDfromDB.sh shell=yes
I am using data driven tests and setting the tags as part of the data. Below is the simplified code:
*** Settings ***
Test Template TN Lookup
*** Testcases ***
Testa Hi TC-1
Bye TC-2
*** Keywords ***
TN Lookup
[Arguments] ${text} #{tags}
Set tags #{tags}
Log to console ${text}
Yet when I run the command:
robot -i TC-1 filename.robot
Both test cases run. How can I specify which tags to run when using set Tags keyword or does this not work?
The -i flag is only processed at the start of the test run and is only influenced by tags present before the tests run. Once the tests start running, you can't change what will or won't be run.
I'm beginner in robot framework. I want to pass values from python file to variable of robot framework, but still can't work successfully.
globe.py is my python file and it's very simple.
a = 'this is testing'
below is test case configuration as robot required
*** Setting ***
|Variables|globe.py
*** Variables ***
|${myTest}|${a}
but robot throw error :
"Error in file: Setting variable '${myTest}' failed: Variable '${a}' not found."
could you give some suggestion on that?
here is screen about my execution steps and result
It seems to me that your example does work. I use the tab delimited approach, but that shouldn't be the cause.
*** Setting ***
Variables globe.py
*** Variables ***
${myTest} ${a}
*** Test Cases ***
A Test Case
Log To Console ${myTest}
This resulted into this response from Robot Framework which appears to be what you're looking for.
Suite Executor: Robot Framework 3.0 (Python 2.7.9 on win32)
==============================================================================
MyLibrary
==============================================================================
MyLibrary.Test
==============================================================================
A Test Case this is testing
| PASS |
------------------------------------------------------------------------------
MyLibrary.Test | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
MyLibrary | PASS |
1 critical test, 1 passed, 0 failed
1 test total, 1 passed, 0 failed
==============================================================================
You can also try to import the variables .py file prior to use..
Import Library <yourPythonFile.py>
#use variables from python variables file after successful import..
The other workaround is using --variablefile option of robotframework.
Test_varaibles.robot
*** Settings ***
*** Variables ***
*** Test Cases ***
print message to console
print msg
*** Keywords ***
print msg
log to console ${msg}
Declare a variable msg in a python file
variable.py
msg='Hello!! This is First msg!'
To pass a variable file, we need to pass –variablefile or -V as a command line argument to pybot
run below command
pybot -V variable.py Test_variables.robot
Result
For more descriptive details, you can also refer below
https://automationlab0000.wordpress.com/2018/11/20/how-to-pass-python-variable-file-in-robotframework/
I try to Run a simple robot framework script in PyCharm.Here is my code:
*** Settings ***
Documentation This is some basic info about the whole suite
Library Selenium2Library
*** Variables ***
*** Test Cases ***
User must sign in to check out
[Documentation] This is some basic info about the test
[Tags] Smoke
Open Browser http://www.google.com.ua chrome
Close Browser
I customized robot framework with PyCharm as it was in videos but when I run this script in terminal of PyCharm, the desired site isn't opened and I get the next information:
C:\Users\user\PycharmProjects\amazon>
C:\Users\user\PycharmProjects\amazon>pybot -d results tests/Amazon.robot
Amazon :: This is some basic info about the whole suite
[ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No browser is open
User must sign in to check out :: This is some basic info about th... | FAIL |
error: [Errno 10054]
------------------------------------------------------------------------------
Amazon :: This is some basic info about the whole suite | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
==============================================================================
Output: C:\Users\user\PycharmProjects\amazon\results\output.xml
Log: C:\Users\user\PycharmProjects\amazon\results\log.html
Report: C:\Users\user\PycharmProjects\amazon\results\report.html
Tell me, please, why this script doesn't open the browser and actions that it should execute and why do I get this error. Thank you.
If the code you posted is literally your code, you're missing at least one space before chrome on the open browser line. There must be two or more spaces between the URL and the browser.
This may not be the only problem, but it's definitely a problem.