Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Qtp realtime scripts


Published on

Published in: Technology, Education

Qtp realtime scripts

  1. 1. For more QTP Scripts, 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(" - Search Jobs").Page(" - Search Jobs").WebList("qf[]").Select "#3" output browser(" - Search Jobs").Page(" - Search Jobs").WebList("qf[]").Select "#2" output 2. How to set values in web edit class?
  2. 2. For more QTP Scripts, 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(" - Search Jobs").Page("Mynaukri").WebEdit("pincode").Set "23" OutputBrowser(" - Search Jobs").Page("Mynaukri").WebEdit("pincode").Set "604202"
  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(" - 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(" - Search Jobs").Page("Mynaukri").WebEdit("pincode").GetTOProperty("text")b= browser(" - Search Jobs").Page("Mynaukri").WebEdit("pincode").GetROProperty("text")msgbox amsgbox
  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,,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(" - SearchJobs").page("Mynaukri").WebList("workAuthOtherCountries[]").Select"#1"browser(" - SearchJobs").page("Mynaukri").WebList("workAuthOtherCountries[]").extendSelect"#3"browser(" - 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"
  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")
  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"&
  7. 7. For more QTP Scripts, else x1=x End If If y<10 Then y1="0"&y else y1=y End If msgbox x1&"/"& y1 &"/"&z to select particular property from weblist and how to set value in webedit ? browser(" - Search Jobs").Page(" - Search Jobs").weblist("qf[]").Select"#3" a=browser(" - Search Jobs").Page(" - Search Jobs").weblist("qf[]").getroproperty("value") msgbox a browser(" - Search Jobs").Page("Mynaukri").WebEdit("pincode").Set"604202" a=Browser(" - Search Jobs").Page("Mynaukri").WebEdit("pincode"). GetROProperty("value") msgbox a9. How to find Data Type of a Variable?
  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)
  9. 9. For more QTP Scripts, 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
  10. 10. For more QTP Scripts, 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")
  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")
  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 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
  13. 13. For more QTP Scripts, www.ramupalanki.com16. how to set value in web page using descriptivesystemutil.Run "iexplore.exe",""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")