Automation Testing, Manual Testing, QTP/UFT 11 , QC/ALM 11 ,SAP TAO, Unix, Selenium, Oracle SQL, Shell Scripting and For Online Trinings to contact me : Cell:+91-8897972059 , Email Id : quicktestprotech@gmail.com

Thursday, November 4, 2010

Set Value in EditBox Using DOM

Set Value in EditBox Using DOM


'***************************************************
Function SetValueinEditBox(PageObject,EditName,Value2Set)
 
 Dim EditObjects
 Dim Edit
 
 set EditObjects=PageObject.getElementsByTagName("INPUT")
 
 For each Edit in EditObjects
 
 If lcase(Edit.name)=lcase(EditName) and lcase(Edit.type)="text" then
            Edit.value=Value2Set
 Exit for
 End If
 
 Next
 
 Set EditObjects= Nothing
 Set Edit=Nothing
 
End Function
 
'***************************************************
'Using above Function without QTP
'***************************************************
'Create Internet Explorer Object
Set IE=CreateObject("internetexplorer.application")
'Make it Visible
IE.Visible=True
'Navigate to a URL
IE.Navigate "http://google.com"
 
'Get Document Object
Set PageObject=IE.Document
 
'Set Value in Google Search Edit Box
SetValueinEditBox PageObject,"q","qtp thirupathi"
 
'***************************************************
'Using above Function in QTP
'***************************************************
 
'Open internet explorere with specific URL
SystemUtil.Run "iexplore.exe","www.google.com"
 
'Get DOM Page object using .Object property
set oPageObject=Browser("name:=Google").Page("title:=Google").Object
 
'Set Value in Google Search Edit Box
SetValueinEditBox PageObject,"q","qtp thirupathi"

0 comments:

Post a Comment

Loading...