문제

나는 Mercury/HP Quicktest Pro 9.1에서 테스트 계획을 "개발"하고 있는데, 여기서 모든 링크 목록을 이메일로 추출하고 각각에 대한 논리를 수행해야합니다.

이 경우 WebMail을 사용하고 있으므로 메시지가 웹 페이지로 나타납니다. 나중에 Outlook을 사용하여보다 현실적인 UX를 복제하고 싶습니다.

저는 테스터가 아닌 개발자입니다. 누구 든지이 추출을 수행 할 "코드"를 제공 할 수 있습니까?

도움이 되었습니까?

해결책

당신은 전화 할 수 있습니다 ChildObjects 방법 주어진 유형의 자식 객체 모음을 반환하는 방법. 예를 들어 Google 홈페이지에서 모든 링크 개체 목록을 얻으려면 다음과 같습니다.

set oDesc = Description.Create()
oDesc("micclass").Value = "Link"
set links = Browser("title:=Google").Page("title:=Google").ChildObjects(oDesc)
For i = 0 To links.Count-1
    reporter.ReportEvent micInfo, links(i).GetROProperty("text"), ""
Next

따라서 이메일 본문이 포함 된 웹 요소를 식별하고 검색의 부모로 사용하면됩니다.

다른 팁

Outlook 경로를 사용하면 QTP의 GUI 코드를 사용하지 않고도 Outlook API를 사용하여 수행 할 수 있습니다.

sServer = "your.server.address.here" '"your.server.address.here"
sMailbox = "JoeSmith" '"mailboxName"

' build the ProfileInfo string
sProfileInfo = sServer & vbLf & sMailbox

' create your session and log on    
Set oSession = CreateObject("MAPI.Session")
oSession.Logon "", "", False, True, 0, True, sProfileInfo

' create your Inbox object and get the messages collection
Set oInbox = oSession.Inbox
Set oMessageColl = oInbox.Messages

' get the first message in the collection
Set oMessage = oMessageColl.GetFirst

If oMessage Is Nothing Then
   MsgBox "No messages found"
Else
   ' loop through inbox
   Do
     With oMessage
        ' message data:
        Debug.Print .Subject & vbCrLf & .TimeReceived & vbCrLf & .Text
        ' this triggers the clever Outlook security dialog:
        'Debug.Print .Sender(1) & vbCrLf & .Recipients(1)
        Debug.Print
     End With

     Set oMessage = oMessageColl.GetNext
   Loop Until oMessage Is Nothing
End If

'Logoff your session and cleanup
oSession.Logoff

Set oMessage = Nothing
Set oMessageColl = Nothing
Set oInbox = Nothing
Set oSession = Nothing
'write qtp script to display names of links in  jkcwebsite page
Option explicit
Dim bro,url,n,desc,childs,i
bro="c:\Program Files\Internet Explorer\IEXPLORE.EXE"
url="http://ieg.gov.in/"
invokeapplication bro&" "&url
'create description for link type
Set desc=description.Create
desc ("micclass").value="link"
'get all links in jkc page
Set childs=browser("title:=Jawahar Knowledge Center").Page("title:=Jawahar Knowledge Center").ChildObjects(desc)
For i=0 to childs.count-1 step 1
    n=childs(i).getroproperty("name")
    print n
Next
n=childs.count
browser("title:=Jawahar Knowledge Center").Close
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top