Class: TCIntegration::TC

Inherits:
Object
  • Object
show all
Defined in:
lib/tc_integration.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTC



61
62
63
# File 'lib/tc_integration.rb', line 61

def initialize
    @tc = TC.get_TC
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &blk) ⇒ Object



89
90
91
# File 'lib/tc_integration.rb', line 89

def method_missing(meth, *args, &blk)
   @tc.send(meth, *args, &blk)
end

Class Method Details

.get_OLE(strAutomationEngine) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/tc_integration.rb', line 73

def self.get_OLE(strAutomationEngine)
    begin
        tc = WIN32OLE.connect(strAutomationEngine)
    rescue WIN32OLERuntimeError
        begin
            tc = WIN32OLE.new(strAutomationEngine)
        rescue WIN32OLERuntimeError
        end
    end
    tc
end

.get_TCObject



65
66
67
68
69
70
71
# File 'lib/tc_integration.rb', line 65

def self.get_TC
    tc = get_OLE("TestComplete.TestCompleteApplication.9") unless tc
    tc = get_OLE("TestExecute.TestExecuteApplication.9") unless tc
    tc = get_OLE("TestComplete.TestCompleteApplication.8") unless tc
    tc = get_OLE("TestExecute.TestExecuteApplication.8") unless tc
    tc
end

Instance Method Details

#LaunchIe(url, timeout) ⇒ Object



107
108
109
110
# File 'lib/tc_integration.rb', line 107

def LaunchIe(url, timeout)
    executable = "C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe"
    StartProcess(executable, url, timeout)
end

#library(name) ⇒ Object



85
86
87
# File 'lib/tc_integration.rb', line 85

def library(name)
    TCLibrary.new(name, @tc)
end

#StartProcess(executable, parameter, timeout) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/tc_integration.rb', line 93

def StartProcess(executable, parameter, timeout)
    shell = WIN32OLE.new('WScript.Shell')
    shell.Run("#{executable} \"#{parameter}\"")

    processName = executable.split(/[\/\\]/).last.split(/\./).first
    sys = @tc.GetObjectByName("Sys")
    x = Now + timeout

    begin
        process = sys.Find("ProcessName", processName)
    end while(!process.Exists && Now < x) 
    return process
end