Reputation: 3
I'm trying to open an autogenerated url sent in an email as part of an activation process. I am unable to get qtp to open that link. Infact,I don't know how to do it.
Any help will be highly appreciated.
Thanks!
Upvotes: 0
Views: 3208
Reputation: 36
Function OpenMailAndVerify(ByVal strSubject,Byval Activity)
Set objApp = CreateObject("Outlook.Application")
Set objNameSpace = objApp.GetNamespace("MAPI")
Set objSyncs = objNameSpace.SyncObjects
Set objSync = objSyncs.Item("All Accounts")
objSync.Start
Set myFolder = objNameSpace.GetDefaultFolder(6)
Set ObjMails = myFolder.Items
Set objFilter = ObjMails
Flag_EmailFound = False
For Each objItem In objFilter
If InStr(objItem.Subject, strSubject) = 1 Then
dtMyDate = objItem.SentOn
strSubject = objItem.Subject
strBody = objItem.Body
StartPos = InStr(strBody, "HYPERLINK")
EndPos = InStr(strBody, "Direct Link to Activity")
EndPos = EndPos - 1
StartPos = StartPos + Len("HYPERLINK") + 2
ActualLink = Mid(strBody, StartPos, EndPos - StartPos)
Flag_EmailFound = True
Exit For
End If
Next
If (Flag_EmailFound) Then
systemutil.Run ActualLink,,,,3
wait 5
If Browser("name:="&Activity&".*").Page("title:="&Activity&".*").Exist(10) Then
Browser("name:="&Activity&".*").Page("title:="&Activity&".*").Highlight
End If
End if
End Function
Upvotes: 1
Reputation: 108
In your record settings you can set the options to record windows applications (location Record > Record and Run Settings > Windows Applications). Here is an example of a script that clicks a login link from an email from stackoverflow -- using UFT 12:
'To open Outlook
SystemUtil.Run "OUTLOOK.EXE"
Window("Microsoft Outlook").Activate
'Double click the top message in the inbox
Window("Outlook Inbox Column").WinObject("Table View").DblClick 118,72
'Find the location of the link within the Message
Window("Message (HTML)").WinObject("Message").Click 212,324
'Verify the link brought me to the Stack Overflow Login page
Browser("Add a login - Stack Overflow").WinObject("AddressDisplay Control").Check CheckPoint("AddressDisplay Control")
Upvotes: 1
Reputation: 13
Use RegExp to identify the link by name and using descriptive programming you can click on the link
Example:
This will be code
urlString = "http://www.cnn.com/.*"
Browser("name:=test - .* - Gmail").Page("title:=test - .* - Gmail").Link("name:=" &urlString).Click
Upvotes: 0