Reputation: 45
I currently have a series of tests that are functional and I want to be able to declare 1 of 2 options at runtime. The tests are currently using XVFB and running headlessly.
The current code that operates the browser is:
Start Virtual Display and enter the URL
[Documentation] Test creates virtual display using XVFB
[Arguments] ${URL}
start virtual display 1440 900
Open Browser ${URL}
set window size 1440 900
sleep ${delay}
If I comment out the start virtual display 1440 900
step, the test case will automatically call the native browser to execute the test steps.
I was hoping there would be an "easy way" to comment or uncomment the start virtual display
test step - maybe by declaring it as a variable?
Upvotes: 0
Views: 2541
Reputation: 1
You can create two tests cases, the first without start virtual display 1440 900. and the other test you set to use start virtual display 1440 900 keyword
Upvotes: 0
Reputation: 1582
You can set variable from command line: http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#setting-variables-in-command-line
Isn't it enough?
Edit based on your code sample:
Start Virtual Display and enter the URL
[Documentation] Test creates virtual display using XVFB
[Arguments] ${URL}
Run Keyword If '${vd}' == 'TRUE' Start Virtual Display 1440 900
Open Browser ${URL}
Set Window Size 1440 900
Sleep ${delay}
And then call your tests with --variable vd:TRUE
Upvotes: 3
Reputation: 6981
In your updated question it seems to me that you are looking for Run Keyword If
functionality that will allow you to use the value of a variable specified on the command line when starting RF to determine the execution of your script. More on the Run Keyword If can be found here
Upvotes: 0