SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Apr 2003
    Location
    Milwaukee, WI, USA
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    FYI, iterating through objects on a page

    I had an interesting problem that Mercury gave me a solution to. Thought you all might be interested in this...

    I have a webtable that displays a list of bank accounts. In the left-most column is a radio button used to select the account to work with. It's relatively easy to search the table and find the account to work with, by row index. The problem is that when using the WebRadioGroup.Select method, the value is an index corresponding to the order that the records were added to the database, which is different than the sort order of the records in the table. Therefore, there is no way for me to match up the row index with the radio button index for the record I want to select.

    If record clicking from top to bottom in the table, I get the following:

    Browser("Browser").Page("Manage Accounts").WebRadioGroup("Account Selectors").Select "1"
    Browser("Browser").Page("Manage Accounts").WebRadioGroup("Account Selectors").Select "0"
    Browser("Browser").Page("Manage Accounts").WebRadioGroup("Account Selectors").Select "2"
    Browser("Browser").Page("Manage Accounts").WebRadioGroup("Account Selectors").Select "4"
    Browser("Browser").Page("Manage Accounts").WebRadioGroup("Account Selectors").Select "3"

    The solution provided from Mercury was to iterate through all the input objects on the page, identify just the radio buttons, then click on the one I want. In this case, the buttons are indexed in the order they appear on the screen.

    <---begin code snippet--->
    'Get array of input objects on the screen
    Set inputObjs = Browser("Browser").Page("Manage Accounts").Object.all.tags("INPUT")

    i=0
    RowToSelect=3 'Row index to be selected
    'Loop through each input object
    for each element in inputObjs
    ' Check if it's a radiobutton.
    if element.getAttribute("type") = "radio" then
    i=i+1
    if(i=RowToSelect) then
    element.click
    end if
    end if
    Next
    <---end code snippet--->

    I can see this technique being VERY useful in other situations where you're having trouble finding a particular object to work with. Kudos to Mercury Tech Support for this one.

  2. #2
    Junior Member
    Join Date
    May 2003
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: FYI, iterating through objects on a page

    Excellent. Thanks for sharing this info.
    Hope to see many more like this.

 

 

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 11.54%
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 02:09 PM.

Copyright BetaSoft Inc.