Hi, This is a code copied from dimitry Motsvich QTP site just go and copy from that site no need to ask for help for this.
Regards Naveen On Tue, Sep 8, 2009 at 9:48 AM, venkata bala subrahmanyam < [email protected]> wrote: > Hi , > > Here am giving the Specific controls for the page.you can get at a time > no.of links ,imags,edit boxes,buttons...etc > if any thing wrong correct it. > > Function Getallspecificcontrols(page,micclass) > set desc=description.create() > desc("micclass).value=micclass > set Getallspecificcontrols=page.childobjects(desc) > End Function > > Function Getalledits(page) > Set Getalledits=Getallspecificcontrols(page,"WebEdit") > End Function > Function GetAllButtons(Page) > Set GetAllButtons = GetAllSpecificControls(Page, "WebButton") > End Function > Function GetAllLinks(Page) > Set GetAllLinks = GetAllSpecificControls(Page, "Link") > End Function > Function GetAllImages(Page) > Set GetAllImages = GetAllSpecificControls(Page, "Image") > End Function > > Set oPage = Browser("Google Sets").Page("Google Sets") > MsgBox "Number of Edits: " & GetAllEdits(oPage).Count > MsgBox "Number of Buttons: " & GetAllButtons(oPage).Count > MsgBox "Number of Links: " & GetAllLinks(oPage).Count > MsgBox "Number of Images: " & GetAllImages(oPage).Count > > > > Regards, > > Venkat > > > > On Sun, Sep 6, 2009 at 10:44 AM, Prasanna Narayanan < > [email protected]> wrote: > >> 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] >> >> >> >> > > > -- > Thanks & Regards > Venkata Bala > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
