1

Mercury/HP QuickTest Pro 9.1 でテスト計画を「開発」しています。この計画では、電子メール内のすべてのリンクのリストを抽出し、それぞれに対してロジックを実行する必要があります。

この場合、私は Web メールを使用しているので、メッセージは Web ページとして表示されます。ただし、後で Outlook を使用して、より現実的な UX を複製したいと考えています。

私は開発者であり、テスターではありません。この抽出を実行する「コード」を誰かに提供してもらえますか?

4

3 に答える 3

3

メソッドを呼び出してChildObjects、特定の型の子オブジェクトのコレクションを返すことができます。たとえば、Google ホームページのすべての Link オブジェクトのリストを取得するには、次のようにします。

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

そのため、メールの本文を含む Web 要素を特定し、それを検索の親として使用するだけで済みます。

于 2009-02-17T02:27:59.040 に答える
1

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
于 2009-02-17T16:04:36.300 に答える
0
'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
于 2011-05-12T07:54:26.763 に答える