SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 9 of 9
  1. #1
    Member
    Join Date
    Sep 2006
    Location
    NYC
    Posts
    257
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Searching table for cell that contains a variable

    A = XYZ123

    Is there a way to search a table for for a cell that contains the value of variable A? The location of the cell will always be different because there are new rows being added by the system all the time. I want to click a link in one of the cells within the same row as variable A.

  2. #2
    Advanced Member Anshoo Arora's Avatar
    Join Date
    Oct 2007
    Location
    New Delhi, India
    Posts
    635
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Searching table for cell that contains a variable

    Try this:

    CONST A = "XYZ123"

    With Browser("").Page("").WebTable("")
    iRow = .GetRowWithCellText(A)

    For ix = 1 to .GetROProperty("cols")
    If InStr(1, LCase(.GetCellData(iRow, ix)), LCase(A)) > 0 Then
    iCol = ix
    Exit For
    End If
    Next
    End With


    -> Cell = iRow, iCol
    Regards,

    Anshoo Arora
    Relevant Codes

  3. #3
    Member
    Join Date
    Sep 2006
    Location
    NYC
    Posts
    257
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Searching table for cell that contains a variable

    [ QUOTE ]
    Try this:

    CONST A = "XYZ123"

    With Browser("").Page("").WebTable("")
    iRow = .GetRowWithCellText(A)

    For ix = 1 to .GetROProperty("cols")
    If InStr(1, LCase(.GetCellData(iRow, ix)), LCase(A)) > 0 Then
    iCol = ix
    Exit For
    End If
    Next
    End With


    -> Cell = iRow, iCol

    [/ QUOTE ]

    Thanks for the input! I will try this out. I have another question...
    How would I click the link that is within the same row but 3 columns over to the right?
    Is it something along the lines of this?
    Browser("Browser").Page("menuPage").Frame("Claims Data Entry Frame").WebTable("Claims Batch Table").GetCellData(iRow, iCol+3).Click

  4. #4
    Advanced Member Anshoo Arora's Avatar
    Join Date
    Oct 2007
    Location
    New Delhi, India
    Posts
    635
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Searching table for cell that contains a variable

    GetCellData only retrieves the text within the cell. What you need is an object reference of within the cell - so you'll need to use ChildItem.

    '.ChildItem(Row, Column, micclass, Index)
    Browser("Browser").Page("menuPage").Frame("Claims Data Entry Frame").WebTable("Claims Batch Table").ChildItem(iRow, iCol+3, "Link", 0).Click
    Regards,

    Anshoo Arora
    Relevant Codes

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

    Re: Searching table for cell that contains a varia

    I wrote a function that may be useful for what you're trying to do. In my case, I was trying to select a radio button in the first cell where the second cell had a text of variable X.

    This meant I needed the value of that radio button...so I used this to find that .value property on that radio button so I could set the value on the 'radiogroup' object in my OR.

    This isn't particularly helpful if you're trying to perform an action on that item...but it is helpful for verifications, or if you need to extract a value from an HTML elements....(for instance, to set a radio button value to a value that is generated...)

    This function uses the page DOM to find the SMALLEST HTML ELEMENT of type "objType" belonging to object "parentObj" that contains the text contained within the variable "text".

    By smallest, I mean if a row contains a table, which contains a row, which contains a table, with a row, and a cell...then 'which cell' contains your text should be the cell closest to your text.

    This assumes:
    - the first match is what you want.
    - if an element contains your text and the same type element, then the contained element is probably containing your text. So if a cell contains your text and another cell...then that cell is probably parent to your table. I didn't need more than that - but you may. (this is mainly for plain-ole-grid situations)

    For instance, if you're seeking a cell with the link in the same row as a cell with your text, then you might do this:

    <font class="small">Code:</font><hr /><pre>
    'get the row that we want to work with based on variable text
    Set myRow = findHTMLObjWithText(Browser("IE").Page("myPage").O bject, "tr", myTextVar)

    'find first cell within row with the link
    Set myCell = findHTMLObjWithText(myRow, "td", "textOfLink")

    'find first link within the cell
    Set myLink = findHTMLObjWithText(myCell, "a", "textOfLink")

    'find first link within the row
    Set myLink2 = findHTMLObjWithText(myRow, "a", "textOfLink")

    Function findHTMLObjWithText(parentObj, objType, text)
    Set objArray = parentObj.getElementsByTagName(objType)
    objIndex = 0
    objFound = False
    while(objIndex &lt; objArray.length AND objFound = false)
    if(instr(objArray(objIndex).innerHTML, text) &lt;&gt; 0 AND objArray(objIndex).getElementsByTagName(objType).l ength = 0) then
    objFound = true
    Set findHTMLObjWithText = objArray(objIndex)
    end if
    objIndex = objIndex + 1
    wend
    if(objFound = false) then
    Set findHTMLObjWithText = Nothing
    end if
    End Function
    </pre><hr />

    You can do something with that link after acquiring the url or text off it, which you may not have known. For instance:

    Browser("IE").Redirect myLink.href -

    or maybe

    Browser("IE").Page("myObj").Link("text:=.*"&amp;my Link.innerHTML&amp;".*).Click


  6. #6
    Member
    Join Date
    Sep 2006
    Location
    NYC
    Posts
    257
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Searching table for cell that contains a varia

    Thanks a lot Anshoo! It worked for me.

    Steven, that looks like a great function. I will play around with it and let you know how it goes (it may take me a while).

    Thanks for the help guys!

  7. #7
    Member
    Join Date
    Sep 2006
    Location
    NYC
    Posts
    257
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Searching table for cell that contains a variable

    [ QUOTE ]


    '.ChildItem(Row, Column, micclass, Index)
    Browser("Browser").Page("menuPage").Frame("Claims Data Entry Frame").WebTable("Claims Batch Table").ChildItem(iRow, iCol+3, "Link", 0).Click

    [/ QUOTE ]

    If the cell I want to click does not have a link, how do I click cell? It looks like the cell is a webelement so I tried the following but I got an error:

    Browser("Browser").Page("menuPage").Frame("Claims Data Entry Frame").WebTable("Claims Batch Table").ChildItem(iRow, iCol, "webelement", 0).Click

    The error said:
    Object required: 'ChildItem(...)'

  8. #8
    Member
    Join Date
    Sep 2006
    Location
    NYC
    Posts
    257
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Searching table for cell that contains a variable

    I tried searching for how to click a webelement using childitems and it looks like a lot of people have this problem but there was never a solution...

    http://www.sqaforums.com/showflat.php?Number=569685

    Does someone happen to know the solution?

  9. #9
    Member
    Join Date
    Sep 2006
    Location
    NYC
    Posts
    257
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Searching table for cell that contains a variable

    Strange. I found the problem. The micclass is case sensitive. It works if I do this...

    Browser("Browser").Page("menuPage").Frame("Claims Data Entry Frame").WebTable("Claims Batch Table").ChildItem(iRow, iCol, "WebElement", 0).Click

 

 

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.71%
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:59 AM.

Copyright BetaSoft Inc.