For more QTP Scripts, www.ramupalanki.com 1. How to select particular property in weblist from browser?    First open obje...
For more QTP Scripts, www.ramupalanki.com       First login naukri account then go to others then go to personal details t...
For more QTP Scripts, www.ramupalanki.com3.settoproperty and gettoproperty and getropropertyIn this line we have set the "...
For more QTP Scripts, www.ramupalanki.comb=emptyThere is no setroproperty. Test object contains only settoproperty and get...
For more QTP Scripts, www.ramupalanki.comset weblists = browser("micclass:=Browser").Page("micclass:=Page").ChildObjects(d...
For more QTP Scripts, www.ramupalanki.comNextOutput         7.         x=day(date)         y=month(date)         z=year(da...
For more QTP Scripts, www.ramupalanki.com               else               x1=x      End If      If y<10 Then             ...
For more QTP Scripts, www.ramupalanki.comThe data type of a variable can be indentified in two VBScript built-infunctions....
For more QTP Scripts, www.ramupalanki.com      output      5Typename directly returns the name of the Sub Datatype of a va...
For more QTP Scripts, www.ramupalanki.com        msgbox typename(x)        output        double10. count the number of chi...
For more QTP Scripts, www.ramupalanki.com12. how to read data from notepad file?‘How to read text from notepad using files...
For more QTP Scripts, www.ramupalanki.comSet y= x.OpenTextFile("E:Documents andSettingsSudhaDesktopgod.txt",1)Set z= x.Ope...
For more QTP Scripts, www.ramupalanki.com16. how to set value in web page using descriptivesystemutil.Run "iexplore.exe","...
Upcoming SlideShare
Loading in...5
×

Qtp realtime scripts

12,487

Published on

Published in: Technology, Education
4 Comments
5 Likes
Statistics
Notes
No Downloads
Views
Total Views
12,487
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
1,066
Comments
4
Likes
5
Embeds 0
No embeds

No notes for slide

Qtp realtime scripts

  1. 1. For more QTP Scripts, www.ramupalanki.com 1. How to select particular property in weblist from browser? First open object repository then click add objects then go to naukri homepage and click naukri homepage title bar then select weblist or entire properties then click ok. Now go to qtp then type script browser("Naukri.com - Search Jobs").Page("Naukri.com - Search Jobs").WebList("qf[]").Select "#3" output browser("Naukri.com - Search Jobs").Page("Naukri.com - Search Jobs").WebList("qf[]").Select "#2" output 2. How to set values in web edit class?www.ramupalanki.com
  2. 2. For more QTP Scripts, www.ramupalanki.com First login naukri account then go to others then go to personal details then add pincode property into object repository the go to qtp type the script In this line we have set the value as 23 to the pincode edit box... this is "SET METHOD" Browser("Naukri.com - Search Jobs").Page("Mynaukri").WebEdit("pincode").Set "23" OutputBrowser("Naukri.com - Search Jobs").Page("Mynaukri").WebEdit("pincode").Set "604202"www.ramupalanki.com
  3. 3. For more QTP Scripts, www.ramupalanki.com3.settoproperty and gettoproperty and getropropertyIn this line we have set the "text property" value as 30 using the "Settoproperty"now the testobject i.e before run time the value for the pincode edit box will be "30"like this we can set the value for any property of a test objectIn this line will also work but we cant see the result.browser("Naukri.com - Search Jobs").Page("Mynaukri").WebEdit("pincode").SetTOProperty "text",30we can check what value we have set to the pincode edit box by using "GETTOPROPERTY"OPTIONa= browser("Naukri.com - Search Jobs").Page("Mynaukri").WebEdit("pincode").GetTOProperty("text")b= browser("Naukri.com - Search Jobs").Page("Mynaukri").WebEdit("pincode").GetROProperty("text")msgbox amsgbox boutputa=30www.ramupalanki.com
  4. 4. For more QTP Scripts, www.ramupalanki.comb=emptyThere is no setroproperty. Test object contains only settoproperty and gettoproperty. Runtime objectcontains only getro property.4.test settings contains 7 tabs1.properties,2.run,3.resourses,4.parameters,5.environment,6.web,7.recovery5. how to multiple select at the same timeFirst login naukri account and go to work authorization property and add objects the type the scriptbrowser("Naukri.com - SearchJobs").page("Mynaukri").WebList("workAuthOtherCountries[]").Select"#1"browser("Naukri.com - SearchJobs").page("Mynaukri").WebList("workAuthOtherCountries[]").extendSelect"#3"browser("Naukri.com - SearchJobs").page("Mynaukri").WebList("workAuthOtherCountries[]").extendSelect"#5"output6. how to get all the link count or weblist count or web element count in the naukri home pageSet descobj = description.Createdescobj("micclass").value= "WebList"www.ramupalanki.com
  5. 5. For more QTP Scripts, www.ramupalanki.comset weblists = browser("micclass:=Browser").Page("micclass:=Page").ChildObjects(descobj)totweblist = weblists.countprint totweblistFor i = 0 to totweblist-1print weblists(i).getroproperty("Name")NextOutputSet descobj = description.Createdescobj("micclass").value= "Link"set links = browser("micclass:=Browser").Page("micclass:=Page").ChildObjects(descobj)totlink = links.countprint totlinkFor i = 0 to totlink-1print links(i).getroproperty("Name")www.ramupalanki.com
  6. 6. For more QTP Scripts, www.ramupalanki.comNextOutput 7. x=day(date) y=month(date) z=year(date) If x<10 Then x1="0"&xwww.ramupalanki.com
  7. 7. For more QTP Scripts, www.ramupalanki.com else x1=x End If If y<10 Then y1="0"&y else y1=y End If msgbox x1&"/"& y1 &"/"&z 8.how to select particular property from weblist and how to set value in webedit ? browser("Naukri.com - Search Jobs").Page("Naukri.com - Search Jobs").weblist("qf[]").Select"#3" a=browser("Naukri.com - Search Jobs").Page("Naukri.com - Search Jobs").weblist("qf[]").getroproperty("value") msgbox a browser("Naukri.com - Search Jobs").Page("Mynaukri").WebEdit("pincode").Set"604202" a=Browser("Naukri.com - Search Jobs").Page("Mynaukri").WebEdit("pincode"). GetROProperty("value") msgbox a9. How to find Data Type of a Variable?www.ramupalanki.com
  8. 8. For more QTP Scripts, www.ramupalanki.comThe data type of a variable can be indentified in two VBScript built-infunctions. 1. Vartype 2. Typename Vartype returns a numeric value indicating the sub datatype of a variable. The below table contains return values that indicate respective subtypes. SubReturn Value Description Datatype 0 vbEmpty Empty (uninitialized) 1 vbNull Null (no valid data) 2 vbInteger Integer 3 vbLong Long integer Single-precision floating-point 4 vbSingle number Double-precision floating-point 5 vbDouble number 6 vbCurrency Currency 7 vbDate Date 8 vbString String 9 vbObject Automation object 10 vbError Error 11 vbBoolean Boolean Variant (used only with arrays 12 vbVariant of Variants) 13 vbDataObjectA data-access object 17 vbByte Byte 8192 vbArray Array Dim x x=10.2 msgbox vartype(x)www.ramupalanki.com
  9. 9. For more QTP Scripts, www.ramupalanki.com output 5Typename directly returns the name of the Sub Datatype of a variable.Sub DescriptionDatatypeByte Byte valueInteger Integer valueLong Long integer valueSingle Single-precision floating-point valueDouble Double-precision floating-point valueCurrency Currency valueDecimal Decimal valueDate Date or time valueString Character string valueBoolean Boolean value; True or FalseEmpty UnitializedNull No valid data<object type> Actual type name of an objectObject Generic objectUnknown Unknown object type Object variable that doesnt yet refer to anNothing object instanceError Error dim x x=10.6www.ramupalanki.com
  10. 10. For more QTP Scripts, www.ramupalanki.com msgbox typename(x) output double10. count the number of child objects of flight reservation applicationinvokeapplication"E:Program FilesMercury InteractiveQuickTestProfessionalsamplesflightappflight4a"Set child_obj=Dialog("text:=Login").ChildObjectsprint child_obj.count11.child objects method(google page)Set child_obj = description.Createchild_obj("micclass").value= "WebEdit"set x = browser("micclass:=Browser").Page("micclass:=Page").ChildObjects(child_obj)totwebedit = x.countprint totwebeditFor i = 0 to totwebedit-1print x(i).getroproperty("Name")Nextwww.ramupalanki.com
  11. 11. For more QTP Scripts, www.ramupalanki.com12. how to read data from notepad file?‘How to read text from notepad using filesystemobjectSet x=createobject("Scripting.FileSystemObject")Set y= x.OpenTextFile("E:Documents andSettingsSudhaDesktopgod.txt",1)While not y.atendofstream a=y.readline()print aWend13. how to write data in the new notepad file?Set x=createobject("Scripting.FileSystemObject")Set z= x.OpenTextFile("E:Documents andSettingsSudhaDesktoplord.txt",2)z.writeline("One")z.writeline("two")z.writeline("three")z.writeline("four")z.writeline("five")14. how to read data from one notepad to wrte another notepad fileSet x=createobject("Scripting.FileSystemObject")www.ramupalanki.com
  12. 12. For more QTP Scripts, www.ramupalanki.comSet y= x.OpenTextFile("E:Documents andSettingsSudhaDesktopgod.txt",1)Set z= x.OpenTextFile("E:Documents andSettingsSudhaDesktoplord.txt",2)While not y.atendofstream a=y.readline() z.writeline(a)print aWend15.how to replace from one particular notepad to another notepadSet x=createobject("Scripting.FileSystemObject")Set y= x.OpenTextFile("E:Documents andSettingsSudhaDesktopgod.txt",1)Set z= x.OpenTextFile("E:Documents andSettingsSudhaDesktoplord.txt",2)While not y.atendofstream a=y.readline() If instr(1,a,"99402") Then a=replace(a,99,88)end if z.writeline(a)print aWendwww.ramupalanki.com
  13. 13. For more QTP Scripts, www.ramupalanki.com16. how to set value in web page using descriptivesystemutil.Run "iexplore.exe","http://google.com"Set x=description.Createx("micclass").value="webedit"browser("micclass:=browser").page("micclass:=page").webedit("index:=1").set"oshoworld"browser("micclass:=browser").page("micclass:=page").webbutton("index:=1").Clickwww.ramupalanki.com

×