Tuesday 7 August 2012

QTP script simple examples here....


## open gmail and check inbox if any new mail by linear fraemwork

Dim iTodayMails
iTodayMails = 0

'Open GMail
SystemUtil.Run "iexplore.exe", "http://www.gmail.com"
'Page Sync
Browser("Gmail").Page("Gmail").Sync

'Login to Gmail
Browser("Gmail").Page("Gmail").WebEdit("UserName").Set "valid gmail login id"
Browser("Gmail").Page("Gmail").WebEdit("Password").Set "valid gmail password"
Browser("Gmail").Page("Gmail").WebButton("SignIn").Click

 
'Page Sync
Browser("Inbox").Page("Inbox").Sync

'Search for emails received today in your inbox
'Logic - The mails received today will have only time in the last(8th) column.
'Time is always followed by am or pm. So the code check for the last 2 characters and matches it with am or pm.
For iR = 1 to 50
    sLastColumnText = Browser("Inbox").Page("Inbox").Frame("Frame").WebTable("Emails").GetCellData(iR,8)
    sLast2Characters = Right(sLastColumnText, 2)
    If sLast2Characters = "am" or sLast2Characters = "pm" Then
        iTodayMails = iTodayMails + 1
    Else
        'Exit For
    End If
Next
'Report the number of  mails received today
Reporter.ReportEvent micPass, "Total Emails Received Today - " & iTodayMails, ""

'Sign out from GMail
Browser("Inbox").Page("Inbox").Frame("Frame").Link("SignOut").Click
Browser("Gmail").Page("Gmail").Sync
'Close the browser
Browser("Gmail").Close()
*****************************************************************










Driver Script created using QTP AOM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Dim testCasePath, resultPath
testCasePath = "D:\QTP\QTP Framework Samples\QTP Linear Framework Demo\GMail Inbox1"
resultPath = "D:\QTP\QTP Framework Samples\QTP Linear Framework Demo\Result"

'Open QTP
Set qtpApp = CreateObject("QuickTest.Application")

'If QTP is not open then open QTP application
If qtpApp.launched <> True Then
    qtpApp.Launch
End If

'Make the QuickTest application visible
qtpApp.Visible = True

'Set QuickTest run options
qtpApp.Options.Run.ImageCaptureForTestResults = "OnError"
qtpApp.Options.Run.RunMode = "Fast"
qtpApp.Options.Run.ViewResults = True

'Open the test in read-only mode
qtpApp.Open testCasePath, True
WScript.Sleep 2000

'set run settings for the testi
Set qtpTest = qtpApp.Test

'Instruct QuickTest to perform next step when error occurs
qtpTest.Settings.Run.OnError = "NextStep"

'Create the Run Results Options object
Set qtpResult = CreateObject("QuickTest.RunResultsOptions")

'Set the results location
qtpResult.ResultsLocation = resultPath

'Run the test
WScript.Sleep 3000
qtpTest.Run qtpResult


No comments:

Post a Comment