Reputation: 13
I want to implement selenium grid with robot framework. I have configured selenium grid hub and two nodes, however I have no idea about how to trigger parallel test case execution after this setup, where to update thread count and parallel tests execution settings in robot framework using python language and selenium 2 lib keywords ? Also, where to assign hub url to trigger the execution? Please suggest possible way out for this. Note: We are using selenium 2 lib keywords in our scripts ,not webdriver keywords, hence I am not able to use 'webdriver.remote' keyword to create hub instance. Thanks!
My framework has : Directory -> multiple test suites-> multiple test cases in each test suites. robot test case execution gets triggered through powershell, which runs on teamcity By using command Python –m robot.run –i $tag However, it triggers sequential execution of test cases, which takes around 10 hrs to complete the execution. So I am looking for the solution to reduce total execution time by running test cases in parallel.
Upvotes: 1
Views: 9530
Reputation: 386352
I have no idea about how to trigger parallel test case execution
Robot doesn't have any built-in support for running tests in parallel, other than the fact that you can run robot twice at the same time. If you want to run the same tests against two different browsers, you'll have to run robot twice, with a different set of parameters (ie: browser specifications) for each test run.
You might be able to use pabot, though it is designed to split one test in to two or more pieces, rather than to run one test twice. You might be able to adapt it to your needs.
There are many other solutions. For example, if you are using a CI server you can set up two jobs to run, and create a third job that is triggered when those two finish, which takes the output from both jobs and combines them into a single report.
If you are on a system with a bash shell, another solution is to write your own test launcher that looks something like the following (though this is completely untested):
# run two robot jobs in the background
robot -A firefox.args /path/to/tests.robot &
robot -A chrome.args /path/to/tests.robot &
# wait for the jobs to finish, then generate a consolidated report
wait
rebot --output ./output.xml firefox/output.xml chrome/.output.xml
In the above example, the .args files are standard robot framework argument files. In them you can specify command line arguments such as the selenium grid URL, the path to a unique folder for output files, etc.
For example:
# firefox.args
--variable GRID_URL: http://127.0.0.1/wd/hub
--variable CAPABILITIES:browserName:ff,version:45,platform:WINDOWS
--outputdir firefox_results
Also, where to assign hub url to trigger the execution?
You do that when you open the browser with the Open Browser keyword. Specifically, with the remote_url
parameter. For example, a test case might look like the following, where ${GRID_URL}
and ${CAPABILITIES}
are defined in the argument files:
*** Settings ***
| Library | Selenium2Library
*** Test cases ***
| Example of connecting to selenium grid
| | [Setup] | Open Browser
| | ... | http://example.com
| | ... | remote_url=${GRID_URL}
| | ... | desired_capabilities=${CAPABILITIES}
So I am looking for the solution to reduce total execution time by running test cases in parallel.
You have two choices:
Upvotes: 4