Hi Joshi,
Use this Below code to find and report number of Links in a Webpage and also
Clicking a Particular Link in a Webpage
Hi U can use this....
*
*
*Dim oAnchors*
*Dim oAnchor*
*Dim blnFound*
*
*
*
*
*Set oDesc = Description.Create()*
*oDesc("micclass").Value = "Link"*
*oDesc("html tag").Value = "A"*
*set Parent=Browser("name:=Google*").Page("title:=Google*")*
*set oAnchors = Parent.ChildObjects(oDesc)*
*blnFound = False*
*'Reporting Number of Links in a Web page*
*Reporter.ReportEvent micDone, "Count", "There are totally "&oAnchors.Count
&" Found in the Webpage"*
*For oAnchor=0 to oAnchors.Count-1*
* MsgBox oAnchors(oAnchor).GetROProperty("innertext")*
*'Finding a Particular Link and Clicking it*
* If oAnchors(oAnchor).GetROProperty("innertext") = "About Google" Then*
*'Reporting a Particular Link which has been Found in the Webpage*
* Reporter.ReportEvent micPass, "Pass", "The Link is found in the Webpage"*
* oAnchors(oAnchor).Click()*
* blnFound = True*
* End If*
* If blnFound = True Then Exit For*
*Next*
*
*
*Set oAnchors = Nothing*
On Sat, Aug 29, 2009 at 5:55 AM, RRJoshi Joshi <[email protected]>wrote:
> Hi,
> I am trying a simple scenario where in I want to count the number of links
> on Google webpage.
> If the no.of links equals 16 then I want the Result as Pass in QTP Test
> Results, for this I am using ReportEvent.
> However, there is some mistake in my code.
> Could anyone please help resolve these?
>
> Browser("Google").Page("Page_Google").Sync
> Set LnkCounter=Browser("Google").Page("Page_Google").Object.links
> NumLinks=LnkCounter.length
> If NumLinks==16 Then
> Reporter.Report Event micPass, "No.of Links", "the user defined step
> passed."
> End If
>
> Thanks in advance!
>
> -RRJoshi
>
> >
>
--
With Best Regards,
Prasanna Narayanan Srinivasan
[email protected]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en
-~----------~----~----~----~------~----~------~--~---