SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1
    Member
    Join Date
    Jan 2008
    Posts
    284
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    How to click on random link on different pages?

    I have some urls where i need click on any link (on all the pages)and finish a request.

    Every page is different and have ton of links,all i need is to pick any link and click it.(i do this for radio group)But, Is there a way to do this for link without knowing the link name/text etc?

    Figuring out the link text on each page consumes lots of manual effort.

    I recorded a link but i don't see any index property for it,so not sure how to deal this scenario.

  2. #2
    Advanced Member
    Join Date
    Aug 2006
    Location
    Other side of the Computer
    Posts
    598
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to click on random link on different pages?

    Yes.

    Set objLinks = Browser().Page().Object.GetElementsByTagName("A")

    intLink = RandomNumber(0,objLinks.Length)

    objLinks(intLink).Click
    ===========================================

  3. #3
    Member
    Join Date
    Jan 2008
    Posts
    284
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to click on random link on different pages?

    Thanks Eagles.The code definitely picks the random link on the page but i ran into another issue.

    I need to focus only on a specific area links which are defined in <div*class="ch">.

    Can you tell me how to get the count of the links of just that class?<div*class="ch">

  4. #4
    Super Member QAGanesh's Avatar
    Join Date
    Sep 2010
    Posts
    1,898
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to click on random link on different pages?

    Try this, not sure if this would work!!


    While StrComp(1, objLinks(intLink).parentNode.getAttribute("class") , "ch", 1)= 0

    objLinks(intLink).Click

    Wend
    Thanks,
    Ganesh Iyer
    Winds of Change

  5. #5
    Member
    Join Date
    Aug 2011
    Posts
    93
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to click on random link on different pages?

    You can try using DP and add the 'class' when you define your object.

    Else you can get all the generic links and then do InStr to find out if the link's innerhtml or outerhtml contain <div class="ch">.
    Regards,
    A n i s h

    [My QTP Blog]

  6. #6
    Super Member QAGanesh's Avatar
    Join Date
    Sep 2010
    Posts
    1,898
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to click on random link on different pages?

    Yepp!!

    I think the first approach is better!!
    Thanks,
    Ganesh Iyer
    Winds of Change

  7. #7
    Member
    Join Date
    Jan 2008
    Posts
    284
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to click on random link on different pages?

    Wrong number of arguments or invalid property assignment error
    on the line -"While StrComp(1, objLinks(intLink).parentNode.getAttribute("class") , "ch", 1)= 0".

  8. #8
    Member
    Join Date
    Jan 2008
    Posts
    284
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to click on random link on different pages?

    Not sure if you are talking to do like this,
    But this didn't work either.As class ch has more objects like image,labels etc other than links.

    Set objLinks = Browser(micclass:=browser).Page("micclass:=page,cl ***:=ch").Object.GetElementsByTagName("A")
    intLink = RandomNumber(0,objLinks.Length)
    objLinks(intLink).Click

    If not can you explain a bit detail?

  9. #9
    Super Member QAGanesh's Avatar
    Join Date
    Sep 2010
    Posts
    1,898
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to click on random link on different pages?

    U can try this, not sure if u have a class property displayed on spying. Else u can use what anish mentioned using the innerhtml

    dim objLink

    set objLink = Description.create
    objLink("html tag").value ="A"
    objLink ("micClass").value = "Link"

    objLink ("Class").value [="ch"

    set objectLink = Browser(micclass:=browser).Page("micclass:=page,cl ***:=ch").ChildObjects(objLink)

    if objectLink(0).exist(5) Then
    objectLink(0).Click
    End If
    Thanks,
    Ganesh Iyer
    Winds of Change

  10. #10
    Member
    Join Date
    Jan 2008
    Posts
    284
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to click on random link on different pages?

    Got this error...

    Object doesn't support this property or method: 'Browser(...).Page'

    Line (96): "set objectLink = Browser("micclass:=browser").Page("micclass:=page, class:=ch").ChildObjects(objLink)".

    I didn't get what Anish was saying...

 

 
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.00%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 07:20 AM.

Copyright BetaSoft Inc.