Friday, June 1, 2012

JMS and UI Automated Testing

My first real experience with using Selenium was not for testing but to automate a process.
ActiveMQ doesn't have a bulk move feature for moving messages between queues, which I needed. It only allows moving a single message in the web UI.

I could have created a JMS queue listener to bulk move messages, but instead I wanted to try some UI automation. My last experience with automation was using AutomatedQA TestComplete and JScript, so it was about time.

So I automated navigating to the queue, clicking the message link, choosing a new queue name in the dropdown, and finally clicking the move link. It was all easy, after I chose to use the deprecated SeleneseTestCase to extend (which just worked as expected) with:
setUp("http://localhost:4444", "*firefox");

I made it a little more complicated by extracting the timestamp and details about the message. To get these I used the CSS and XPath locator formats to pull from the HTML on the page (such as a specific row and column in a table):
css=div.message pre
xpath=//table[@id='header']//tr[11]//td[2]
These allowed me to add more logic, such as deleting messages before a certain date or not moving messages with specific content.

The only real issues I faced were timing and browser support. 
For example, the page load times varied per environment making me add in extra time for loading to work in all. I used Thread sleep in some cases since the waitForPageToLoad was not always reliable. 
Originally I started using Firefox (*firefox) but it stopped working after updating to version 14. I switched to Chrome (*googlechrome) which worked without issue.

No comments:

Post a Comment