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

Selenium Testrail integration


I am new to TestRail tool and wanted to integrate all my Selenium automation test cases with TestRail.

Can anybody help me?

Gracy Layla


Some threads to read about Selenium integration. Test Rail is designed to record the pass/failure of the Automation test via the Test Rail API.


What language binding are you using for Selenium? You would want to integrate with the same language.

Once that is known better advice can be given on how to proceed. For example there are a number of Python Testrail API class files one can used to get a jump on the effort.


Hi Gracy,

Here is my strategy which eliminates the process of typing cases into TestRail or doing some kind of import and massaging of test cases. With this approach, tests can be executed via normal means via command line, supporting your normal test framework like mvn test, bundle exec, etc where you can run locally or from some triggered ci job via pull requests through git and/or jenkins.

My first step was to create a custom test case field in TestRail called external_id. This external_id is unique to any test in your Selenium suite, by combining class_name;test_method_name for languages such as Java, Ruby, etc… or if using Cucumber, external_id would be something like Feature title;scenario or Feature title;scenario;celldata.

Within your test listener, the idea is to use the testrail api library to query the project / suite / test cases to see if there are any existing tests with a matching external id. If it does not exist, use the api to generate the test case before sending results. This can be made efficient by having the listener generate an array of cases / external_ids before any of the scenarios execute.

After each scenario is finished, check the external_ids array, if there is no match, hit the add_case endpoint. If people rename test cases or move them to new classes, then the external id is suddenly different, and a new test case will be created in TestRail the next time your suite runs.

Using this strategy has a number of benefits, as you don’t manually type in new test cases for Selenium in TestRail at all, and there no cross-references to maintain on test case ids.

We use Ruby and created a gem to store all the modules and methods that our test listener uses to interact with TestRail. This strategy should be a good start!