Tuesday, 6 November 2012

Yahoo Project on QTP



Write QTPScript along with VBScript code in QTP tool for below yahoo mail scenario

Ø  Launch Yahoo mail website
Ø  Do login
Ø  Click inbox link
Ø  Select “new mail” to compose a mail
Ø  Fill fields in compose page
Ø  Send a mail
Ø  Do logout
Ø  Close the yahoo site



Option explicit
Dim bro, url, wsho (windows shell object)
‘Launch Yahoomail website using VBscript
Bro= “C:\Program Files\Internet Explorer\iexplore.exe”
invokeapplication (bro&” “&url)
‘Do login using QTPscript in DP
With browser (“title:=.*)
          With.page (“title:=.*)
                .webedit (“name:=login”) .set “mindqtestingtools”
                .webedit (“name:=passwd”) .setsecure “509791ddb446a18e57e8cde98362f
    00483c1534594797788ed42”
                .webbutton(“name:=signin”) .click
          End with
End with
‘Go to inbox link using QTPscript in Dp
With browser (“title:=.*)
          With.page (“title:=.*)
                .link(“name:=inbox”, “index:=0”) .click
          End with
End with
‘Go to new message using QTPscript with DP
With browser (“title:=.*)
          With.page (“title:=.*)
                .webbutton (“name:=new”) .click
                .link (“name:=email message”).click
          End with
End with
‘Fill mail compose page using QTPscript with DP
With browser (“title:=.*)
          With.page (“title:=.*)
                .webedit(“name:=to”) .set mindq@yahoo.com
                .webedit(“name:=cc”) .set Johnatmindq@yahoo.com
                .webedit(“name:=subj”) .set “QTP Tool”
 ‘Automate Keyboard input for filling body using VBScript
                .webedit(“name:=subj”) .click
           Set wsho=createobject(“wscript.shell”)
           Wsho.sendkeys (“{TAB}”)
           Wsho.sendkeys (“{TAB}”)
           Wsho.sendkeys (“Hi Mindq, How are you doing………”)
‘Keyboard automation completed
                .webbutton(“name:=send”, “index:=0”) .click          
            End with
End with
‘Do logout using QTPscript in DP
With browser(“title:=.*”)
          With.page(“title:=.*”)
                .link(“name:=Signout”) .click
            End with
End with
‘Close Yahoo website using QTPscript in DP
Browser(“title:=.*”) .close


NOTE:  In above test script (VBScript and QTPScript), we automated yahoo mail compose page “body object” using keyboard automation indirectly because the body object is a webelement and visible as webedit.  For keyboard automation, we used “sendekeys” ( ) method along with “wscript.shell” components in the script.

This sendkeys ( ) method can take keyboard keys as input while automating misbehaving objects, and cache objects in webpages.  Cache means, a list of items depends on given text in an editbox.  Exp:  Google search box

SYNTAX:  set wsho=createobject(“wscript.shell”)
                 wsho.sendkeys(“send any keys”)

In above syntax, keyboard keys are two types, general keys and functional keys.  Functional keys must be enclosed by curly braces { }, and keys are case sensitive.

                                                KEYBOARD INPUTS
KEYNAME
SENDKEYS METHOD
BACK SPACE
{BACKSPACE} OR {BS} OR {BKSP}
BREAK
{BREAK}
CAPS LOCK
{CAPSLOCK}
DEL OR DELETE
{DEL} OR {DELETE}
DOWN ARROW
{DOWN}
END
{END}
ENTER
{ENTER} OR ~
ESC
{ESC}
HELP
{HELP}
HOME
{HOME}
INS OR INSERT
{INS} OR {INSERT}
LEFT ARROW
{LEFT}
NUM LOCK
{NUMLOCK}
PAGE DOWN
{PGDN}
PAGE UP
{PGUP}
PRINT SCREEN
{PRTSC}
RIGHT ARROW
{RIGHT}
SCROLL LOCK
{SCROLLLOCK}
TAB
{TAB}
UP ARROW
{UP}
F1 TO F16
{F1} TO {F16}
SHIFT
+
CONTROL
^
ALT
%
+
\+
^
\^
%
\%
~
\~
a-z
a-z
0-9
0-9
BLANK SPACE

OTHERS
OTHERS

2 comments:

  1. Anonymous3/20/2013

    Write QTPScript along with VBScript code in QTP tool for below yahoo mail scenario

    Ø Launch Yahoo mail website
    Ø Do login
    Ø Click inbox link
    Ø open each mail of mailbox and test mail body spelling and grammatical mistakes
    Ø Do logout
    Ø Close the yahoo site

    plz write that above program

    ReplyDelete
  2. Anonymous10/10/2013

    Hi
    I have done an onlilne training in QTP. But how can I show in my resume that I am at confident level to work in a QTP project.

    ReplyDelete