SPONSORS:






User Tag List

Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1
    Senior Member
    Join Date
    Jul 1999
    Location
    Burlingame CA 94010
    Posts
    502
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Coding Challenge #2

    Write a function which clicks a random link on the current browser page from among all links on the current page.

    Write the function in ONE line.



  2. #2
    Senior Member
    Join Date
    Jan 2001
    Posts
    750
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Coding Challenge #2

    BrowserPage.HtmlLink("${RandPick(BrowserPage.GetLi nks())}").Click()

    This if you just want to load the page.
    Browser.LoadPage(RandPick(BrowserPage.GetLinks()))

    ------------------

  3. #3
    Senior Member
    Join Date
    Aug 1999
    Location
    Cambridge, UK
    Posts
    470
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Coding Challenge #2

    Well, that works if you've already defined your GetLinks() method of class BrowserChild, but I don't see it myself (as of 5.5. SP2). John Green, are we restricted to using core 4Test methods and functions, or are we allowed our own custom extensions?

    ------------------

  4. #4
    Senior Member
    Join Date
    Jul 2000
    Posts
    117
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Coding Challenge #2

    Hmmm ... BrowserChild.GetLinks() is defined in 5.5 HF 4 ...

    Weird that it wouldn't be there in SP2 ...

    The question, though, is valid in general for these little exercises -- but I suspect John's intent is to use only methods / functions that come "out of the box" with Silk.

    On that note -- John -- nice stuff! Keep it coming! This is good practice for everybody on the forum.


    ------------------

  5. #5
    Senior Member
    Join Date
    Jul 1999
    Location
    Burlingame CA 94010
    Posts
    502
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Coding Challenge #2

    Perfect, GK,

    It could also be done using a "#" index tag.


  6. #6
    Senior Member
    Join Date
    Jul 1999
    Location
    Burlingame CA 94010
    Posts
    502
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Coding Challenge #2

    Brent,

    I think BrowserChild.GetLinks () has been there for quite a while, maybe 5.01?

    John

  7. #7
    Senior Member
    Join Date
    Jan 2001
    Posts
    750
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Coding Challenge #2

    GetLinks() was hidden in 5.32, but definitely in 5.5. I found it in help. Obviously my answer assumes that the web page has no tables, and all the urls are returned correctly through GetLinks, and everything are unique.

    Since GetLinks return the URL of the links, if two links with different caption but their url are the same or similar(ex:test, test1, silk gets confused sometimes), my answer will not work properly(clarification for the purist:P

    Also I am interested in the 1 line answer that uses the # tag. My question is how do you know how many links there are in 1 line?

    [This message has been edited by GodKnows (edited 06-18-2002).]

  8. #8
    Senior Member
    Join Date
    Jul 1999
    Location
    Burlingame CA 94010
    Posts
    502
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Coding Challenge #2

    Maybe its harder than I thought to solve with a class index tag.

    5600 points to the class index solution winner.


  9. #9
    Senior Member
    Join Date
    Jul 2000
    Posts
    117
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Coding Challenge #2

    Ok, I'll bite ...

    ------------------

  10. #10
    Senior Member
    Join Date
    Jul 1999
    Location
    Burlingame CA 94010
    Posts
    502
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Coding Challenge #2

    Brent gets 5600 points !!!!!!!!

 

 
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
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin 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 06:00 AM.

Copyright BetaSoft Inc.