Need help navigating to an element

3 posts, 0 answers
  1. S
    S avatar
    15 posts
    Member since:
    May 2011

    Posted 24 Oct 2011 Link to this post

    I have a web page with two almost identical grids on the page.  The grids are made up of tables that look something like
    Grid 1
    <Table> x-grid-row
    <TBody>
    <TR>
    <td> x-grid3-Risk
    <td>x-grid3-Name

    Grid2
    <Table> x-grid-row
    <Tbody>
    <tr>
    <td>x-grid3-Reward
    <td>x-grid3-Name


    I've had succes getting to the information in the name column by using the following commands

     

    Dim

     

     

    my_Frame As ArtOfTest.WebAii.Core.Browser = ActiveBrowser.Frames.BySrc("~Lending/Admin/RiskModel.mvc/index")

     

     

     

    Dim

     

     

    myRows as Element = my_Frame.Find.AllByAttributes("class=~x-grid3-Reward")

     

    Dim myElement = myRows(i).getNextSibiling

    What I haven't been able to get to work out is how to use code to use "Click" with one of the x-grid3-name cells.  Is there a way to convert the Element to an HTML control?  Every method I have tried just causes a compile error - so any suggestions would be appreciated.

    Thanks



  2. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 26 Oct 2011 Link to this post

    Hello S,

    You can click on the element with your current code like this:

    Dim my_Frame As ArtOfTest.WebAii.Core.Browser = ActiveBrowser.Frames.BySrc("~Lending/Admin/RiskModel.mvc/index")
    Dim myRows As Element = my_Frame.Find.AllByAttributes("class=~x-grid3-Reward")
    Dim myElement = myRows(i).getNextSibiling

    ActiveBrowser.Actions.Click(myElement)


    Yes, you can convert the element to an HTML control like this:

    'Insert appropriate find logic here
    Dim elem As Element = Nothing
     
    Dim cell2 As HtmlControl = elem.[As](Of HtmlControl)()
    cell2.Click()

    It's best to access and click the HTML control and not the base element, like this:

    'Insert appropriate find logic here
    Dim my_Frame As Browser = Nothing
     
    Dim myRows As ReadOnlyCollection(Of HtmlTableCell) = my_Frame.Find.AllByAttributes(Of HtmlTableCell)("class=~x-grid3-Reward")
    Dim myCell As HtmlTableCell = myRows(2)
     
    'DOM click
    myCell.Click()
     
    'Simulate real mouse click
    myCell.MouseClick()

    All the best,
    Anthony
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. S
    S avatar
    15 posts
    Member since:
    May 2011

    Posted 27 Oct 2011 Link to this post

    Thanks for the help
Back to Top