Micro Focus QTP (UFT) Forums
Gmail: Compose Mail Functionality - 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: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Gmail: Compose Mail Functionality (/Thread-Gmail-Compose-Mail-Functionality)



Gmail: Compose Mail Functionality - kishore.gkk - 08-09-2010

I never thought I have to struggle 12 hrs to automate ‘compose mail’ functionality in gmail. But still I am unable to execute it successfully. I have been struggling to identify the objects of ‘compose mail link”, “To text box”, “subject text box”, “send button”. I can understand it is a simple issue but in real I am struggling,

The code i am using.
'*****************************************************
Code:
If  Browser("title:=Gmail.*").Page("title:=Gmail.*").WebElement("innertext:=Compose Mail", "html id:=:rd", "html tag:=B").Exist Then
    Browser("title:=Gmail.*").Page("title:=Gmail.*").WebElement("innertext:=Compose Mail", "html id:=:rd", "html tag:=B").Click -9999, -9999
    Browser("title:=Gmail.*").Page("title:=Gmail.*").Sync
    If Browser("title:=Gmail.*").Page("title:=Gmail.*").WebEdit("name:=to", "class:=dK nr l1", "rows:=2").Exist Then
        Browser("title:=Gmail.*").Page("title:=Gmail.*").WebEdit("name:=to", "class:=dK nr l1", "rows:=2").Set "<xyz@gmail.com> "
        If  Browser("title:=Gmail.*").Page("title:=Gmail.*").WebEdit("name:=subject").Exist Then
            Browser("title:=Gmail.*").Page("title:=Gmail.*").WebEdit("name:=subject").Set "hi"
            If  Browser("title:=Gmail.*").Page("title:=Gmail.*").WebButton("name:=Send").Exist Then
                Browser("title:=Gmail.*").Page("title:=Gmail.*").WebButton("name:=Send").Click -9999, -9999
                Browser("title:=Gmail.*").Page("title:=Gmail.*").Sync
            Else
                   MsgBox( "Send button Not found")
                
            End If
        Else
            MsgBox( " Subject text box Not found")
            
        End If
    Else
        MsgBox( "To text box not found")
            End if
Else
    MsgBox( "Compose Mail link not found")
    
End If

'***************************************************
In some runs, some of the objects are being identified by QTP and in the next run same objects are not being identified.

I thought i would use Object repositary to store the objects and get them identified. But the above mentioned objects are lying under frames whose name starts with 'c'. So i cant use c.* for all the frames.

Note: Before you suggest any code, please run it once on gmail and if it is passing then only put down here. Otherwise i end up loosing more time in implementing your code.

In some posts i read use the below to click on compose mail

Code:
Browser("title:=Gmail.*").WebElement("html id:=:rd").Click

but i didn't work

Thanks,
kishore


RE: Gmail: Compose Mail Functionality - kishore.gkk - 08-10-2010

Here is the code which is working. Thanks to Anshoo arora the moderator.

Code:
With Browser("title:=Gmail.*").Page("title:=Gmail.*")
    If .WebElement("innertext:=Compose Mail", "html tag:=SPAN").Exist(10) Then
        .WebElement("innertext:=Compose Mail", "html tag:=SPAN").Click
        If .WebEdit("name:=to").Exist(10) Then
            .WebEdit("name:=to").Set ""
            If .WebEdit("name:=subject").Exist(10) Then
                .WebEdit("name:=subject").Set "hi"
                Setting.WebPackage("ReplayType") = 2
                If .WebElement("innertext:=Send", "html tag:=B", "index:=0").Exist(10) Then
                    .WebElement("innertext:=Send", "html tag:=B", "index:=0").Click
                    .Sync
                Else
                    MsgBox( "Send button Not found")
                End If
                Setting.WebPackage("ReplayType") = 1
            Else
                MsgBox( "Subject text box Not found")
            End If
        Else
            MsgBox( "To text box not found")
        End if
    Else
        MsgBox( "Compose Mail link not found")
    End If
End With



RE: Gmail: Compose Mail Functionality - adityapant27 - 12-25-2012

But why we use Exist(10)... I dont understand it.. please let me know/
Thanks
Adi


RE: Gmail: Compose Mail Functionality - elango87 - 12-25-2012

Exist is used to check if the object is present in the screen and do the operations on the object.

for example, ,

Code:
Browser("").Page("").Image("").Exist(5)

If we use the code above QTP will wait a maximum of 5 seconds for the Image("") object to appear. If it appears, it will execute the next line of code.

If the object doesn't appear with in 5 seconds, the step will fail.

Hope you got it.

Thanks,
Elango


RE: Gmail: Compose Mail Functionality - newqtp - 02-15-2013

I am trying to delete email from gmail account and I am stuck. I have tried different combination but no luck.

Code:
If  Browser("name:=Your CarMax validation code.*").page("Title:=Your CarMax validation code.*").webtable("class:=Bs nH iY").Exist   Then
Browser("name:=Your CarMax validation code.*").page("Title:=Your CarMax validation code.*").webtable("class:=Bs nH iY").Webtable("class:=cf gJ").Image("class:=hA T-I-J3").Click
' Click delete this message on the fly out , below line should click the delete this message but not clicking
'giving error as too many web element.
Code:
'Browser("name:=Your CarMax validation code.*").page("Title:=Your CarMax validation code.*").webtable("class:=Bs nH iY").webelement("class:=cj", "outtertext:= Delete this message").Click

End If

Finally I got it work by below line of text
1) read the email you want to delete by getrowtextcell("Gmail")

2) Now click the trash can on top bar.
Code:
Browser("name:=.*").page("Title:=.*").webelement("class:=T-I J-J5-Ji nX T-I-ax7 T-I-Js-Gs ar7").Submit

But I would like to delete by fly out "delete this message" option as above code delete all the mails which are grouped by that text.


RE: Gmail: Compose Mail Functionality - newqtp - 02-15-2013

Now working code doesn't work, I am back to square 1.. Need help