Thursday 4 March 2010

Test Complete and Ruby

So I'm working on a test automation project using Test Complete and desperate to get away from having to use Test Complete's gigantic front end. So here's the good news. Test Complete has an open API. (Well first you need to purchase a licence). But this means that I can use Ruby to connect to TC and Cucumber as my test framework. Once in the Cucumber domain you can look at Hudson or another CI tool.

So the first thing I did was to convert the TCConnect.bas file which contains all of the methods required.

First Make the connection:

require 'Win32API'
require 'win32ole'

cTestCompleteApplication = "TestComplete.TestCompleteApplication.7"
begin
searchTC = WIN32OLE.connect(cTestCompleteApplication)
searchTC.visible = true
rescue WIN32OLERuntimeError
Thread.new {searchTC = WIN32OLE.new(cTestCompleteApplication)}
searchTC.visible = true
end

def is_runner_active
puts "Checking Runner Activity..."
#Check TC IsRunning
timeout = 1
while searchTC.Integration.IsRunning == false do
sleep(2)
timeout = timeout + 1
puts "waiting for Test Complete to start up...runner state: #{searchTC.Integration.IsRunning}"
if timeout > 15 then
puts "Test complete is going no where"
exit
end
end
end

#Open up Test Complete Project
DATA_PATH = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "TCProject"))
filepath = File.join(DATA_PATH, "TCAutomationProject.pjs")

$runner = searchTC.Integration.GetObjectByName("Runner")

if searchTC.Integration.IsRunning == true then
puts "Test Complete is already running"
else
puts "Test Complete is NOT already running..."
searchTC.Integration.OpenProjectSuite(filepath.gsub("/","\\"))
TestEngine = searchTC.Manager.ManagersByString("{555A3A53-8D35-4F93-9570-00662CF627C6}")
Thread.new { TestEngine.RunConnected("TestLog", "Automation_Script"); is_runner_active; }
#Give TC a chance to startup correctly
sleep(1)
puts "Test Complete started..."
end

testedApps = searchTC.Integration.GetObjectByName("TestedApps")
connectedApp = testedApps.MyConnectedApp.Run

Thursday 14 May 2009

Windows Testing In Ruby

A while ago I required an automation script for a windows application and I couldn't find a fully operational open source automation tool in Ruby. Some work had previously been carried out called GuiTest, which had made a great start but for whatever reason wasn't continued.

So incorporating some of the parts of GuiTest into a new project (Wintir::Windows Automation In Ruby) I've started to assemble some simple windows object recognition.


http://rubyforge.org/projects/wintir/

An example of the script would be...

#Attach an exisiting calculator
com = Wintir::Com.attach("SciCalc","Calculator")
#Click the button "C" followed by "1"
com.button(:caption => "C", :name => "Button").click
com.button(:caption => "1", :name => "Button").click


#Change the menu option to Scientific
com.file_menu(:menu_path => "View>Scientific")

Another example...

#Open menu "Insert>Object"
com.file_menu(:menu_path => "Insert>Object")

#Return the result of a value, from a list box being displayed on a dialog
result = com.dialog(:dialog_name => "Date and Time").list_box(:name => "ListBox").find_string("11 December 2008")

The project is in its early but I've managed to at least release a first version which can be found...

http://rubyforge.org/frs/?group_id=7364





Monday 4 May 2009

Ruby Automation in Functions

I've been working on a web desktop application, which allows business user's to re-use automation code to develop automated test scripts.

www.raif.org.uk

The application is currently being designed using a Ruby on Rails a Model View Controller framework with the ext javascript toolkit.

raif is still in development, however the following images display some of the functionality available in beta. As raif is s an open source project all the of the code can be found in http://rubyforge.org/projects/raif/





Future Development

A list of the full development plan can be found on the raif.org.uk website