Micro Focus QTP (UFT) Forums
Scripting Gmail - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Scripting Gmail (/Thread-Scripting-Gmail)



Scripting Gmail - cbeggs - 11-19-2010

I'm trying to create a script using QTP to compose an email in Gmail.
So far I have the login working but am unable to locate the compose mail webElement using descriptive programming. Please take a look at my code and offer any feedback that might help. Thanx.
Here is my code so far...

Code:
Dim ie
Set ie = CreateObject("InternetExplorer.Application")
ie.Visible = True
ie.Navigate "www.gmail.com"

'Define variables for Gmail Home Page
Dim objBrowser, objGmailHmPg, objUser, objPass, objSignIn

'create browser object
Set objBrowser = Description.Create()
objBrowser("title").value = "Gmail: Email from Google - Windows Internet Explorer"

'Create Gmail Home Page object
Set objGmailHmPg = Description.Create
objGmailHmPg("title").value = "Gmail: Email from Google"

'Create user name textbox object
Set objUser = Description.Create()
objUser("html tag").value = "INPUT"
objUser("type").value = "text"
objUser("name").value = "Email"

'Create password textbox object
Set objPass = Description.Create()
objPass("html tag").value = "INPUT"
objPass("type").value = "Password"
objPass("name").value = "Passwd"

'Create sign in button object
Set objSignIn = Description.Create()
objSignIn("name").value = "Sign in"

Browser(objBrowser).page(objGmailHmPg).WebEdit(objUser).Set "xxxxx@email.com"
Browser(objBrowser).page(objGmailHmPg).WebEdit(objPass).Set "password"
Browser(objBrowser).page(objGmailHmPg).WebButton(objSignIn).Click

Set objCompose = Description.Create()
objCompose("innertext").value = "Compose mail"
objCompose("html tag").value = "DIV"

If Browser("title:=Gmail - Inbox.*").Page("title:=Gmail - Inbox.*").Frame("html tag:=IFRAME", "html id:=canvas_frame").WebElement(objCompose).Exist Then
    msgbox "true"
else
    msgbox "false"
End if

ie.Quit



RE: Scripting Gmail - ngocvo3103 - 11-19-2010

Hi cbeggs,

I think you should add more property to identify the WebElement

Code:
Set objCompose = Description.Create()
objCompose("micclass").Value = "WebElement"
objCompose("innertext").value = "Compose mail"
objCompose("html tag").value = "DIV"
objCompose("class").Value = "J-K-I-Jz"

Hope to hear you soon.

Ngoc Vo


RE: Scripting Gmail - cbeggs - 11-19-2010

I think I know why I'm having trouble accessing this button. It appears that
the Compose Mail button in Gmail is a custom button created by Google.

http://stopdesign.com/archive/2009/02/04/recreating-the-button.html

So unless anyone here knows anything about this and can help me out, I think I'm going to throw in the towel on this one.