QTP Dynamic objects



Programmatic descriptions enable us to create temporary versions of test objects to represent objects from our application.

We can perform operations on those objects without referring to the object repository.

For example, suppose an edit box was added to a form on your Web site. You could use a programmatic description to add a statement in a user-defined function that enters a value in the new edit box, so that QuickTest can identify the object even though you never recorded on the object or added it to the object repository

Syntax
TestObject("PropertyName1:=PropertyValue1", "..." , "PropertyNameX:=PropertyValueX")

TestObject—the test object class.
PropertyName:=PropertyValue—the test object property and its value. Each property:=value pair should be separated by commas and quotation marks.

Example
Browser("Mercury Tours").Page("Mercury Tours").WebEdit("Name:=Author", "Index:=3").Set "Mark Twain”

Window("Text:=Myfile.txt - Notepad").Move 50, 50
Window("Text:=Myfile.txt -Notepad").WinEdit("AttachedText:=Find what:").Set "hello"
Window("Text:=Myfile.txt - Notepad").WinButton("Caption:=Find next").Click


What are File system objects in QTP?
The FileSystemObject (FSO) object model allows us to use the familiar object.method syntax with a rich set of properties, methods, and events to process folders and files.


How to Create a file system object in QTP?
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")


How to perform File operations in QTP?
Dim fso, f1
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.CreateTextFile("c:\qattestfile.txt", True)
Set f1 = fso.opentextfile("C:\testqat",2)
‘1 – Reading , 2 – Writing, 9 - Appending
f1.writeline "welcome to qatutorial.com"


How to Copy a file in QTP?
Dim fso

Set fso = createobject("Scripting.FileSystemObject")

fso.copyfile "C:\test","C:\test1“
‘copyfile source,destination,true or false
‘true – if file exists, overwrites
‘false – if file exists, does not copy

style="display:block"
data-ad-client="ca-pub-9945402454384428"
data-ad-slot="3540880857"
data-ad-format="autorelaxed">