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
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:
- Create manual test cases in Quality Center
- Create automated test cases using Selenium/JUnit
- Create a mapping between QC test cases and automated test cases
- Run automated test cases as normal
- Perform mapping (parse JUnit results, generate QC mapped results)
- 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.