SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 3 of 3
  1. #1
    Member
    Join Date
    Nov 2004
    Location
    pune
    Posts
    31
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    click on a radio button in Web Table using child item

    There's a column of radio Buttons in a Web Table.
    The select event of the radio button's are getting identified as-
    Browser("").Page("").WebRadioGroup.Select "PartyID=2,rowID=3"

    I want to select the radio button irrespective of the value i.e "PartyID=2,rowID=3", as this value keeps on changing for each radiobutton.

    Tha code I used is-
    Set WebEditObj=Browser.Page.WebTable.ChildItem(intRow, 1,WebRadioGroup,0)
    WebEditObj.Click

    QTP is not clicking on the radio button & is not giving any error.
    If I use the code-
    Set WebEditObj=Browser.Page.WebTable.ChildItem(intRow, 1,WebRadioGroup,0)
    WebEditObj.Select

    QTp throws the error-wrong no. of arguments, which is correct as I have to give a value or an index with Select event.

    Please suggest.Can I use SetTOProperty.If so, how?

  2. #2
    Senior Member
    Join Date
    Oct 2003
    Location
    Kyiv, Ukraine
    Posts
    302
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: click on a radio button in Web Table using child item

    this should work:
    '##########################################
    radiosNumber = Browser("br").Page("page").WebTable("tbl").ChildIt emCount (3,4, "WebRadioGroup")
    Set rgWithinCell = Browser("br").Page("page").WebTable("tbl").ChildIt em (3, 4, "WebRadioGroup", 0)

    rgWithinCell.Select "#1"
    '##########################################

    as far as i understood there are some mistakes in your code, first is in this statement:
    Set WebEditObj=Browser.Page.WebTable.ChildItem(intRow, 1,WebRadioGroup,0)
    the micClass (WebRadioGroup) argument should be within " " ;

    second is in the Select method, it requires an argument

  3. #3
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: click on a radio button in Web Table using child item

    Well after lots of RND i have come with the solution to the problem. But let us first disucss some issues

    When we use
    Browser("br").Page("page").WebTable("tbl").ChildIt em (3, 4, "WebRadioGroup", 0)

    Now this give us the WebRadioGroup object of QTP that work as if we have a group of RadioButtons. Now suppose if we have 3 checkboxes on a web page with same name then using the above statements returns a QTP object which QTP treats in its own way. So should i make it a web element, well may be yes

    Set rgWithinCell = Browser("br").Page("page").WebTable("tbl").ChildIt em (3, 4, "WebElement", 0)

    But i dont know what is the problem with QTP and its returning me the object that is currently selected and not the one that is actually present in that cell.

    Now consider the below html code
    <INPUT TYPE="radio" CHECKED NAME="testPath" VALUE="swot">
    <INPUT TYPE="radio" NAME="testPath" VALUE="swot2">
    <INPUT TYPE="radio" NAME="testPath" VALUE="swot3">
    now in html this creates three object with name testPath in the DOM structure of the page and QTP recognize all of the as part of single object of type WebRadioGroup. So there is no solution possible by just using the normal QTP functions.

    So we will see the solution using DOM
    Below is the HTML code of the example that i have used

    <table border=1 cellpadding=0 style='mso-cellspacing:
    1.5pt'>
    <tr >
    <td >
    <p><INPUT TYPE="radio" CHECKED NAME="testPath" VALUE="swot">/<span
    class=SpellE>swot</span></p>
    </td>
    </tr>
    <tr >
    <td >
    <p><INPUT TYPE="radio" NAME="testPath" VALUE="swot2">/swot2</p>
    </td>
    </tr>
    <tr >
    <td >
    <p><INPUT TYPE="radio" NAME="testPath" VALUE="swot3">/swot3</p>
    </td>
    </tr>
    </tr>
    </table>
    Append the Code by the HTML and BODY Tag as i cannot post these tags int the post.

    Well now saving this file in example.html and then recording a script to add the neccessary objects. Add the web table object seperately to the script

    now we use the below code
    SystemUtil.Run "C:\Documents and Settings\tarun_lalwani\Desktop\example.html","","C :\Documents and Settings\tarun_lalwani\Desktop","opennew"
    Set WObj=Browser("Browser").Page("Page").WebTable("Web Table").Object.rows(2).cells(0)
    'Get the DOM object for 3rd row and column 1

    This give me the TD node of the 3rd row in the table
    now if we see the HTML code for this node is
    <td >
    <p><INPUT TYPE="radio" NAME="testPath" VALUE="swot3">/swot3</p>
    </td>
    So TD node has one child node <P> which in turn has one child node INPUT. This INPUT element is the one that i want to access. To get the value to be used for selection

    so if i say WObj.Childnodes(0) this gives me the <P> node as Wobj points to the <TD> node

    so WObj.Childnodes(0).Childnodes(0) give me acces to the specific input element in the cell and

    WObj.Childnodes(0).Childnodes(0).value gives me the value of this radio button which can be used to check the radio button

    Browser("Browser").Page("Page").WebRadioGroup("tes tPath").Select WObj.Childnodes(0).Childnodes(0).value

    I know that it not one the best way to represent the solution but i thought of giving as much details as possible

 

 

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 03:54 AM.

Copyright BetaSoft Inc.