Search This Blog

Friday, July 3, 2015

Accessing Web Objects Using DOM Methods

ElementFromPoint Method

 
x=Browser("name:=Google").Page("title:=Google").WebEdit("name:=q").GetROProperty("x")  
y=Browser("name:=Google").Page("title:=Google").WebEdit("name:=q").GetROProperty("y")  
Browser("name:=Google").Page("title:=Google").Object.elementFromPoint(x,y).Value="QTP" 'Sets value in web edit using coordinates  

GetElementsByTagName Method

Set obj= Browser("name:=Google").Page("title:=Google").Object.getElementsByTagName("INPUT")  
inCount=obj.Length-1  
For i=0 to inCount  
   If obj(i).Name="q" and obj(i).Type="text" Then  
    Browser("name:=Google").Page("title:=Google").Object.getElementsByTagName("INPUT")(i).Value="QTP"        'Sets   value in web edit using tag name.  
   End If  
Next  

GetElementsByName Method:

Set obj= Browser("name:=Google").Page("title:=Google").Object.getElementsByTagName("INPUT")  
inCount=obj.Length-1  
For i=0 to inCount  
  If obj(i).Name="q" and obj(i).Type="text" Then  
   Browser("name:=Google").Page("title:=Google").Object.getElementsByName(obj(i).Name)(0).Value="QTP" 'Sets  value in web edit using element's name.  
   End If  
Next  

GetElementByID Method: 

1.Browser("name:=Google").Page("title:=Google").Object.getElementByID("XXXX").Value="QTP" 'Sets value in web edit using element's ID  

Verifying Child Object Existence Using Contains Method: 

1.Set objWebEdit=Browser("name:=Google").Page("title:=Google").WebEdit("name:=q").Object  
2.msgbox Browser("name:=Google").Page("title:=Google").webTable("index:=0").Object.contains(objWebEdit)'If the webtable contains the specified child object, then Contains method will return True. 

Mouse Hover Register User Function

'******************************************************
Function Hover(obj)
  x = obj.getroproperty("abs_x") + (obj.getroproperty("width"))/2
  y = obj.getroproperty("abs_y") + (obj.getroproperty("height"))/2
  Set devicereplay = CreateObject("Mercury.devicereplay")
  devicereplay.MouseMove x, y
  Set devicereplay = Nothing
  Wait 1
End Function

'******************************************************
Registeruserfunc "Link", "Hover", "Hover" 

'******************************************************

List of features & enhancements to UFT 12.5

Here below are the list of features & enhancements to UFT 12.5 :
ØCross-Browser Testing:
                HP enhanced chrome recording ability and also we can use one script that works against IE, Firefox, Safari, Chrome
                Provided an option to select browser to run
                Receive single report that shows the results of all the test executions against all the different browsers
ØUFT Runtime Engine:
                This is a separate installation piece now, which allows users to easily deploy test scripts to other machines (includes new license type)
ØUsability:
                Light-weight  and HTML based report feature. Now we can share results without needing to have results viewer installed
ØIntegration & Technologies:
                HP has added functionality that allows users to integrate with source-control tools like Git and Subversion
ØFlexible Consumption: UFT License + Lean FT License + UFT Runtime Engine License
                When you buy the UFT bundle you’re getting both the UFT and LeanFT licenses. (This applies if you already have an existing Unified Functional Testing license.) We can decide which flavor we want to       use to create test scripts. We can mix and match. We can also install both UFT and LeanFT on the same machine.
ØMobile:
                We can use the UFT SPY and highlight on mobile user interfaces. There is also a run mobile test option using UFT Jenkins plugin.