1

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.

1
  • 1
    Have a look at github.com/mkorpela/pabot. Not sure it's what you need though. Commented May 4, 2016 at 19:50

1 Answer 1

4

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:

  1. use pabot to automatically split one large suite into several parallel test runs
  2. manually create multiple jobs for different parts of your test suite (eg: pybot tests/suite1; pybot tests/suite2; pybot tests/suite3, etc.)
Sign up to request clarification or add additional context in comments.

6 Comments

Thank you for the quick reply .. !! I have added few more details in my question.
As suggested I used below two solutions : 1.When I used Pabot 0.24 , I am getting below error message : Command used to trigger execution: C:[path to test suite] > pabot test suite name (txt file ) “”[ ERROR ] Unexpected error: TypeError: argument of type 'module' is not iterable Traceback (most recent call last): None No tests to execute Elapsed time: 0 minutes 0.6 seconds “”
I also tried below commands, but faced similar issue :- C:[path to test suite] > pabot test suite name (txt file ) –parallel 2 --pabotlib --pabotlibhost -- pabotlibport 8270 - --C:[path to test suite] > pabot –command –m test suite name (txt file ) ---command-end –parallel 2 –pabotlib –pabotlibhost –pabotlibport 8270
2. Also tried using selenium grid to run multiple test cases concurrently on same machine with different nodes. I used open browser keyword to pass hub url and set desired capabilities. Currently, I can trigger the execution of two different suites in parallel with pybot command. However, I have no idea how to trigger execution in parallel for all test cases at once.
@ank15: The error "[ERROR ] Unexpected error: TypeError: argument of type 'module' is not iterable" is most likely something related to your specific test cases. Please post an issue to github.com/mkorpela/pabot/issues
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.