Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.

Problems with integrate Selenium+TestRail


Hello all,

I’m trying to integrate TestRail with automatic functional tests testRail and therefore I have a request for help because I’m doing something like that the first time.
I have done the integration and now if I run the tests I save my results in testRail.

I would like to identify the test case in the testRail by idCase in my automatic tests case.
At the moment I am forced to enter idRun + idCase But idRun can be different every time. (screen2)

  1. Do you have any suggestions?
  2. How to send idRun and all idCase contained in it after pressing the button to start automatic tests?
  3. What should be placed in the UI script to run the tests after clicking the start automatic tests button?

I’m drew a picture of the architecture I want to do. screen.



If I understand what you want to do - you want Test Rail to kick off the test in Selenium with a button in Test Rail - correct?

If that is correct - technically you might be able to get that to work however, that is not what Test Rail is designed to do. The more correct way to integrate Test Rail is to run the test(s) in Selenium and then update the test results in Test Rail via the API.


First of all you should understand what there are tests in a test run but not cases. These are different objects with different IDs.

I the best way for you, it’s to send only run ID to your code on test framework side. Then you should get the list of tests of the test run (jast call methed get_tests by testrail api) and you will get all information you need to execute tests (each test contain the correspondent case ID, so you can find your selenium test by this ID) and save result back into testrail (just call add_result method by api).


I am actually leading a project where we are trying to do this very thing. For our design, we have separated the Selenium (auto test) part from the Test Rail API code. This way, we will use the parsed data (instructions) to drive the testing framework.

The real problem is how to translate natural language into code logic. For that, I used a Rules Engine to infer what methods to do based on text pattern recognition. We’re just starting, but I am very optimistic about our chances. The prototype I built worked pretty well.


Well, we map each test method to a test case using attributes, if you see the image, we have created @SlTest and have defined an element to capture the testcaseid.

We use the API “/index.php?/api/v2/add_results_for_cases/” to log results at end of the test class in @AfterClass after storing the results of all the tests in that test class. TestRun has to be created and passed on to log the results.