More on QC Integration with Selenium

I received another email about integrating HP Quality Center with Selenium.  It’s a fairly common theme, so I thought I’d post the letter with my response here.  There may be some duplication with previous posts.

 > Hi Aaron,
 > I want to integrate to QC using Selenium WebDriver and I am using
 > Java. Do you have any approach to connect to QC using Java?
 > Can we directly upload the script to QC--is that possible?
 > Thanx in advance

My response:

Java can use the OTA API to connect to QC but it requires a Java-COM bridge (OTAClient.DLL is a Windows COM assembly). JACOB is an open source Java-COM bridge. I haven’t tried the Java-COM bridge myself, but have implemented solutions with C# and Python.

Selenium scripts can’t be uploaded to QC directly (it doesn’t have anywhere to store them) but you can write scripts in other languages supported by VAPI-XP. It may be possible to use Selenium in that case (for instance using Python or Perl — I don’t think there is a VBScript or JScript interface to Selenium) but I’ve never tried that approach. I prefer to do my coding in an IDE and use version control.

But I have written Selenium tests in Java using JUnit and integrated them with Quality Center. I take a modular approach. First, by running the tests as usual in Java, then using a utility to update test results in Quality Center. I have an example app written in C# on Github that does this.

It requires a simple CSV with two columns: the QC test name and status (PASS/FAIL). Generating this CSV simply requires mapping JUnit test cases to QC test cases. I accomplish this with annotations. See this example.

You should be able to integrate test results from Selenium (and other tests) by using the QCIntegration utility without altering your regular workflow once you have the mapping implemented. Alternately, you could use the example in QCIntegration to add a step to your tests which calls Quality Center to update each test result after it runs, but this is less efficient and error prone since it requires establishing a network connection to QC for each test to succeed.

So, using my method, your workflow looks like this:


  1. Create manual test cases in Quality Center
  2. Create automated test cases using Selenium/JUnit
  3. Create a mapping between QC test cases and automated test cases


  1. Run automated test cases as normal
  2. Perform mapping (parse JUnit results, generate QC mapped results)
  3. Run QCIntegration to update results in Quality Center.

By the way, if you use the QCIntegration utility and have any questions, feature requests, bug reports, or patches for QCIntegration, I’d love to have them.

9 thoughts on “More on QC Integration with Selenium

  1. Hi Aaron,

    The link for QC Integration is not loading. It says The page you were looking for doesn’t exist. Can you please provide correct link for it.

  2. hi aaron can u provide detailed mapping steps between QC and automated test cases. How do we perform mapping ? Can u provide a detailed description please..

    1. Amit,

      I map JUnit test cases to QC test cases by adding an annotation to the test case @test_case_id=123 and reflecting on the test method.

      First I create an annotation:

      public @interface QCIntegration {
      public String test_case_id();

      Then I add the annotation to my test case

      public class AnnotatedTestCase {
      public void MyTest() {
      //...test steps
      String test_case_id = getTestCaseId()

      I reflect over the test case method to get the annotation:

      public String getTestCaseId() throws NoSuchMethodException, SecurityException {
      StackTraceElement[] trace = Thread.currentThread().getStackTrace();

      int CALL_STACK_POSITION = 2; // This may change depending on how deeply nested this method is
      String callingMethodName = trace[CALL_STACK_POSITION].getMethodName();

      Method method = this.getClass().getMethod(callingMethodName);
      Annotation qcIntegration = method.getAnnotation(QCIntegration.class);
      String test_case_id = ((QCIntegration) qcIntegration).test_case_id();
      return test_case_id;

      Another way is to parse the test results and compare the test results to a simple mapping file.

      JUnitTestName = QCTestName

      If you don’t want to build the infrastructure, I’d recommend that method. That way QC integration can be done asynchronously to test execution.

  3. Hi Aaron,

    nice job!
    Actually i can set the status of a complete test in the lab. Is it possible to set the status of the steps and post something into the “actual” field?


    1. Thanks Roland. I’d love to answer your question, but I don’t have access to QC (or the docs) right now, but I think the answer is yes. I’d love to write a mini-book on using the OTA API if I got the time.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s