Search This Blog

Sunday, December 9, 2012

Run QTP when the monitor is off/minimized


Change the following registry settings:-
Step 1: Goto HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\MicTest
Step 2: Locate the key “SkipEnvironmentChecks”
step 3: Change the value to “1″ (Default value is 0)
Step 4: Restart the QTP.

Thursday, November 15, 2012

Automating a checkbox in a combo box



val = Dialog(DialogName).WinComboBox(ComboBoxName).GetVisibleText
Num = Dialog(DialogName).WinComboBox(ComboBoxName).GetItemsCount

For i = 0 to Num-1
          selectitem = Dialog(DialogName).WinComboBox(ComboBoxName).GetItem(i)
          Pos = Instr(1, val,selectitem)
          If Pos <> 0 Then
                   On Error Resume Next
                   Dialog(DialogName).WinComboBox(ComboBoxName).Select i
          End If
          val = Dialog(DialogName).WinComboBox(ComboBoxName).GetVisibleText
Next


checkval = "Local"

For i = 1 to 2
          selectitem = Dialog(DialogName).WinComboBox(ComboBoxName).GetItem(i)
          Pos = Instr(1, checkval,selectitem)
          If Pos <> 0 Then
                   On Error Resume Next
                   Dialog(DialogName).WinComboBox(ComboBoxName).Select i
          End If
Next

Monday, May 9, 2011

Run Script - For associating all libraries, repositories and environment variables

Dim App 'As Application
Set App = CreateObject("QuickTest.Application")
App.Launch
App.Visible = True
App.Test.Settings.Launchers("Windows Applications").Active = False
App.Test.Settings.Launchers("Windows Applications").Applications.RemoveAll
App.Test.Settings.Launchers("Windows Applications").RecordOnQTDescendants = True
App.Test.Settings.Launchers("Windows Applications").RecordOnExplorerDescendants = False
App.Test.Settings.Launchers("Windows Applications").RecordOnSpecifiedApplications = True
App.Test.Settings.Run.IterationMode = "rngAll"
App.Test.Settings.Run.StartIteration = 1
App.Test.Settings.Run.EndIteration = 1
App.Test.Settings.Run.ObjectSyncTimeOut = 120000
App.Test.Settings.Run.DisableSmartIdentification = False
App.Test.Settings.Run.OnError = "NextStep"
App.Open "D:\Ranger Automation\Main Script\SmokeTest", False
App.Test.Settings.Resources.DataTablePath = "D:\Ranger Automation\Data Folder\Session Data\SmokeTest.xls"
App.Test.Settings.Resources.Libraries.RemoveAll

App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functional Layer\Ebeam_MainWindow.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functional Layer\iAS-Div.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functional Layer\IAS_FunctionalLayer.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functional Layer\Review.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functional Layer\Run_InspectionQueue_FunctionalLayer.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functional Layer\SetUp.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functional Layer\SetupRun_ReviewWafer_FunctionalLayer.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functional Layer\Setup_Button_ValidationStatus.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functional Layer\SetUp_Run.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functional Layer\Test_TestSummaryGrid.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functional Layer\Utilities.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functional Layer\WaferSetup.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functional Layer\WaferSetup_FunctionalLayer.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functions\Applic_Path.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functions\Calling Logger.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functions\Framework_Functions.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functions\Job Queue.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functions\KT-Logger.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functions\MachineLaunch.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functions\New_TestCase.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functions\QTP_Logger.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functions\Ranger_Recipe.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functions\Ranger_SubFunction.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functions\RunJobQueue.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functions\Utility.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functions\WPP_Feature.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functions\WPP_FunctionLayer.vbs")
App.Test.Settings.Resources.Libraries.Add("D:\Ranger Automation\Class\Functions\WPP_Functions.vbs")
App.Test.Settings.Web.BrowserNavigationTimeout = 60000
App.Test.Settings.Web.ActiveScreenAccess.UserName = ""
App.Test.Settings.Web.ActiveScreenAccess.Password = ""

App.Folders.RemoveAll

Dim objRepositoryFolder,repositoryFolder,repositoryFiles,repositoryFile
Set objRepositoryFolder = CreateObject("Scripting.FileSystemObject")
Set repositoryFolder = objRepositoryFolder.GetFolder("D:\Ranger Automation\Object Repository")
Set repositoryFiles = repositoryFolder.Files

App.Test.Actions("Action1").ObjectRepositories.RemoveAll

For Each repositoryFile In repositoryFiles
App.Test.Actions("Action1").ObjectRepositories.Add "D:\Ranger Automation\Object Repository" & "\" & repositoryFile.Name
Next

Call App.Test.Environment.LoadFromFile("D:\Ranger Automation\Class\Environment.xml",true)

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' System Local Monitoring settings
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
App.Test.Settings.LocalSystemMonitor.Enable = false
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Log Tracking settings
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
With App.Test.Settings.LogTracking
.IncludeInResults = False
.Port = 18081
.IP = "127.0.0.1"
.MinTriggerLevel = "ERROR"
.EnableAutoConfig = False
.RecoverConfigAfterRun = False
.ConfigFile = ""
.MinConfigLevel = "WARN"
End With

Tuesday, January 18, 2011

Getting the number of files with same extension in a folder

Flag = 0
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(sPath) 'Path of the folder
Set oFile = oFolder.Files
For each sFile in oFile
Pos = Instr(1,sFile.name,".jpeg",1) ' change the extn as required.
If Pos <> 0 Then
Flag =Flag +1
End If
Next
msgbox Flag

Monday, January 3, 2011

Reading data from a virtual table

This post will help you in reading data from a virtual table. This is really helpful and we took a very long time to come up with this solution. It is very simple but that thought process took some time to set in ;). So here we go.

Create the virtual table using the virtual objects manager. The properties available to you would be Width, Height, Rows, Columns, x, y.

Get the height and width of a single cell by dividing the table width and height by the column and row values respectively.

x and y are the values of the top left corner of the first cell, to get the bottom right corner add the height and width calculated for a single cell. Now use the GetVisibleText property with the parent object.

Like,
Say you have a grid or table that is recognized as a winobject, and you create a virtual table for it. Now the code to read the data from the first cell of the table would be:

val = Window(" ").Page(" ").WinObject(" ").GetVisibleText(x,y,x1,y1)
msgbox val

Wednesday, December 1, 2010

Setting the same value in all child objects

There might be cases where you want to enter the same value in all the objects of the same class like an edit box. This is particularly useful when checking for field level validations. The approach to be followed can be to identify all the childobjects in the page belonging to the same class, and then trying to set the value or retrieve a value. The below piece of code can be used to enter the same text in all the WebEdit objects in the YahooMail page.


Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = True
objIE.Navigate "www.yahoomail.com"

Browser("Google").Page("Yahoo! Mail: The best").Sync
Set objDesc = Description.Create
objDesc("micclass").Value = "WebEdit"

Set Child = Browser("Google").Page("Yahoo! Mail: The best").ChildObjects(objDesc)

For iCount = 0 to Child.count -1
Child(iCount).Highlight
Child(iCount).Set "Divya Rakesh"
Next

Associating all the library files from a folder before start

Using the below code you can add all the library files in folder from a vbs script at the beginning of the session. This same vbs file can be used for doing all the settings as well, like opening QTP, opening the test, associating all resources and then running the test. You can easily get the script by modifying the script that is generated when the user gives Generate script in the File Settings. The below part of the code can be updated to this vbs file to associate all the library file from a given folder.


Set objFile = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFile.GetFolder("E:\Automation\Library")
Set objFiles = objFolder.Files

For each sFile in objFiles
sExtn = Right (sFile, 3)
If sExtn = "vbs" or sExtn = "qfl" Then
App.Test.Settings.Resources.Libraries.Add sFile
End If

Next