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
Search This Blog
Wednesday, December 1, 2010
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
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
Subscribe to:
Posts (Atom)