This is a migrated thread and some comments may be shown as answers.

Need help navigating to an element

2 Answers 78 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
S
Top achievements
Rank 1
S asked on 24 Oct 2011, 03:11 PM

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 Answers, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 26 Oct 2011, 08:06 PM
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
0
S
Top achievements
Rank 1
answered on 27 Oct 2011, 12:52 PM
Thanks for the help
Tags
General Discussions
Asked by
S
Top achievements
Rank 1
Answers by
Anthony
Telerik team
S
Top achievements
Rank 1
Share this question
or