Micro Focus QTP (UFT) Forums

Full Version: QTP Script for opening gmail and enter details
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi
I am trying to create Descriptive program for open gmai and enter username password.

Could you tell me how can i wirte the descriptive program for login a gmail page.
Ans:
Code:
systemutil.Run "iexplore.exe", "www.gmail.com"
browser("micclass:=browser").page("micclass:=page").WebEdit("name:=Email").Set "abcdd"
browser("micclass:=browser").page("micclass:=page").WebEdit("name:=Passwd").Set "bnghhj"
browser("micclass:=browser").page("micclass:=page").WebButton("name:=Sign in").Click


Note: Make sure that fast close all active browser bcoz i hav given browser("micclass:=browser").so if more than one browser is opened then it can not identify..If u want u can change the property value of browser and can giv browser("name:=Gmail: Email from Google").page("name:=Gmail: Email from Google")..By using dis no need to close other browser.
Code:
Dim EditToSearch,EditValueToSet, NumberOfEdits,webButtonToSearch,LinkValueToSet, NumberOfWebButton, EditToSearch4pass,EditValueToSet4pass, NumberOfEdits4pass

'initOutExcel()
'This is the value of the 'name' property for the WebEdit object we want to find.
EditToSearch = "Email"
EditValueToSet = "yourlogin"


'Create a description object to help retrieve all WebEdit objects in a specific page.
Set loginDesc = Description.Create()
    loginDesc("micclass").Value = "WebEdit"
    loginDesc("name").Value = "Email"

'Retrieve all WebEdit objects in this page
Set EditCollection = Browser("Browser").Page("Gmail: Email from Google").ChildObjects(loginDesc)

NumberOfEdits = EditCollection.Count

'Search for a specific Linkobject and set its value
For i = 0 To NumberOfEdits - 1
    If EditCollection(i).GetROProperty("name") = EditToSearch Then
       EditCollection(i).Set EditValueToSet
       ' WriteResults "Enter UserID Succesfully","Gmail User Login","User Enter value"
     End If
Next


'Password Entry

'This is the value of the 'name' property for the WebEdit object we want to find.
EditToSearch4pass = "Passwd"
EditValueToSet4pass = "yourpass"


'Create a description object to help retrieve all WebEdit objects in a specific page.
Set passDesc = Description.Create()
    passDesc("micclass").Value = "WebEdit"
    passDesc("name").Value = "Passwd"

'Retrieve all WebEdit objects in this page
Set EditCollection = Browser("Browser").Page("Gmail: Email from Google").ChildObjects(passDesc)

NumberOfEdits4pass = EditCollection.Count

'Search for a specific Linkobject and set its value
For i = 0 To NumberOfEdits - 1
    If EditCollection(i).GetROProperty("name") = EditToSearch4pass Then
       EditCollection(i).Set EditValueToSet4pass
        'WriteResults "Enter password Succesfully","Gmail password","User Enter value 'password'"
     End If
Next

'This is the value of the 'name' property for the Link object we want to find.
webButtonToSearch = "Sign in"

'Create a description object to help retrieve all Link objects in a specific page.
Set webButtonDesc = Description.Create()
    webButtonDesc("micclass").Value = "WebButton"
    webButtonDesc("name").Value = "Sign in"

'Retrieve all Link objects in this page
Set webButtonCollection =Browser("Browser").Page("Gmail: Email from Google").ChildObjects(webButtonDesc)

NumberOfWebButton =webButtonCollection.Count

'Search for a specific Link object and set its value
For i = 0 To NumberOfWebButton - 1
    If webButtonCollection(i).GetROProperty("name") = webButtonToSearch Then
      webButtonCollection(i).Click'Set EditValueToSet
    End If
'Browser("Browser").Page("Gmail: Email from Google").WebButton(webButtonToSearch).Click
' WriteResults "Login Succesfully","Corporate User Login","User Login With Sysadmin"
Next

If Browser("Browser").Dialog("Security Alert").Exist Then
    Browser("Browser").Dialog("Security Alert").WinButton("Yes").Click
End If
Requesting Everyone to please wrap your code in proper tags, while posting
refer Help