Open particular script routine from VBS file
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Open particular script routine from VBS file
I want to know how to open a Project suites Script routine from a VBS file when testcomplete is already opened with out again invoking the testcomplete
Regards,
G.Someswara Rao
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
G.Someswara Rao
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried with the following code in vbs file
Sub MySub
' Initialize variables
sProjectNameFileName = "C:\Users\u304080\Desktop\26_07_2013\Shakedowns\Shakedowns.pjs"
sProjectName = "Scenarios"
sUnitName = "aaaaaa"
sRoutineName = "funHi"
' Creates the application object
Set TestCompleteApp = CreateObject("TestComplete.TestCompleteApplication")
' Obtains the integration object
Set IntegrationObject = TestCompleteApp.Integration
' Opens the project
IntegrationObject.OpenProjectSuite sProjectNameFileName
' Checks whether the project was opened
If Not IntegrationObject.IsProjectSuiteOpened Then
MsgBox "The project suite was not opened."
Exit Sub
End If
' Runs the routine
IntegrationObject.RunRoutine sProjectName, sUnitName, sRoutineName
End Sub
It doesnot respond ..Can you please check it !!!
Regards
G.Someswara Rao
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well this works fine on my side:
MsgBox "Start"
' Creates the application object
Set TestCompleteApp = CreateObject("TestComplete.TestCompleteApplication")
' Obtains the integration object
Set IntegrationObject = TestCompleteApp.Integration
' Opens the project
IntegrationObject.OpenProjectSuite "C:\myProjectSuite.pjs"
' Checks whether the project was opened
If Not IntegrationObject.IsProjectSuiteOpened Then
MsgBox "The project suite was not opened."
else
MsgBox "Project opened"
End if
MsqBox "End"
Keep in mind that TC must not be running before starting the script. Check your tasklist for wscript.exe running forever.
You might want to check C:\Users\yourAccount\AppData\Roaming\SmartBear\TestComplete\9.0\Sileng.log for issues.
In this case, I would not use vbscript without a proper debugging tool. You might want to checkout Powershell.
Sincerely
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply, well you said that TC must not opened before starting the VBS file. My requirement is "Start the Script routine when TestComplete is already opened", Can u please help me in that way.
Regards,
G.Someswara Rao
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It makes it easier if it not already running but you can connect to it if its running. The following works:
function getTestRunner(){
if (Get-Process | Where-Object {$_.ProcessName -eq "TestComplete"}){
try {
return [System.Runtime.InteropServices.Marshal]::GetActiveObject("TestComplete.TestCompleteApplication")
} catch {
Write-Host "Could not connect to running testRunner. Will kill it and try again"
}
} else {
# if the script was started with no licenses left, this function will never return.
return New-Object -ComObject "TestComplete.TestCompleteApplication"
}
}
As for VB the documentation states:
The first step in using TestComplete as a COM server is connecting to it. To create a connection, you have to create a reference to the TestComplete
object. This object implements methods and properties to connect and work with TestComplete. You can create a connection by calling Visual Basic’s CreateObject
function and passing the TestComplete.TestCompleteApplication
or TestComplete.TestCompleteApplication.9
program id to it as a parameter:
Set TestCompleteObject = CreateObject("TestComplete.TestCompleteApplication")
This line launches a new instance of TestComplete. If TestComplete is already running, use the Set TestCompleteObject = GetObject(,"TestComplete.TestCompleteApplication") line instead.
Sincerely
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
G.Someswara Rao
