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

Retrieving Images/Textbox/radio from Datagrid

8 Answers 98 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
sivaraj
Top achievements
Rank 1
sivaraj asked on 05 Jul 2011, 11:46 AM
I was using Webaii version and used the datagrid to access the images by using the below (Code snippet)

 
objApplication = Browser.SilverlightApps().GetApp(0);
objApplication.Connect();

DataGrid 
objDataGrid =  objApplication.Find.ByName<DataGrid>("dataGrid");
objDataGrid.Rows[0].Cells[0].Find.ByName<RadioButton>().User.Click();

However when i try using the above one with the latest version (), I got warnings as the Rows are depericiated and use RowElements instead. But RowElements are not FrameworkElement type and hence i couldnt fetch the image/textbox/radio inside the Cell. It would be great if you can give a sample to fetch the above using the latest methods (upgraded).

Also if am continue using the above method (using rows), will this method be removed from the framework in later releases. Is there any harm using the depreciated methods in the latest framework if it is working fine in my cases.

Thanks in advance.

8 Answers, 1 is accepted

Sort by
0
Stoich
Telerik team
answered on 05 Jul 2011, 01:01 PM
Hi Sivaraj,
     you can rewrite your code like this:
objApplication = Browser.SilverlightApps().GetApp(0);
objApplication.Connect();
 
DataGrid  objDataGrid =  objApplication.Find.ByName<DataGrid>("dataGrid");
objDataGrid.RowElements[0].CellElements[0].CastAs<DataGridCell>().Find.Find.ByName<RadioButton>("someName").User.Click();
A major difference is that CellElements[0] will return IDataGridCell (an Interface) and not a "normal" DataGridCell element. We've implemented this in order to improve code reusability for WPF/Silverlight testing.
One consequence is that you'll need to cast IDataGridCell to a Silverlight DataGridCell (unless you're doing WPF testing in which case you'll have to cast it to a WPF DataGridCell).

That being said I agree that the IDataGridCell interface should contain a Find method (which would have eliminated the need for casting in the above logic). I've logged this as a bug, you can track its progress here:
http://www.telerik.com/support/pits.aspx#/public/test-studio/6750

Kind regards,
Stoich
the Telerik team
Register today for a live 'What's New in Test Studio R1 2011 SP2' event on Tuesday, July 19 at 2pm EST!

Have you looked at the new Online User Guide for Telerik Test Studio?
0
sivaraj
Top achievements
Rank 1
answered on 02 Aug 2011, 02:54 PM

Hi while I am using the following code in version 2011.1.609.0 it will shows the exception "object reference not set to an instance of object"

objApplication = Browser.SilverlightApps().GetApp(0);
objApplication.Connect();
   
RadGridView objRadGrid =  objApplication.Find.ByName<RadGridView>("radgridview");
int i = objRadGrid.Rows.Count

Similarly I am not able to proceed with objRadGrid.Rows[5].Cells[4].text.

So I am using the following work around.

RadGridView objRadGrid =  objApplication.Find.ByName<RadGridView>("radgridview"); 
GridViewRow objRows = objRadGrid.Find.AllByType<GridViewRow>();
int i = objRows.Count

But the above code returns only the visible rows count. I am not able to proceed for the invisible rows. objRows.ScrollToVisible() , click, etc all are not working.

Help me to proceed on this.

Thanks and Regards,
Siva
0
Cody
Telerik team
answered on 03 Aug 2011, 12:20 AM
Hi Sivaraj,

You do not need objApplication.Connect();. Rewrite your code that gets the application to this:

SilverlightApp theApp = ActiveBrowser.SilverlightApps()[0];


You are correct that you can only get the visible rows from a RadGridView of a Silverlight application. This is a limitation of the VisualTree contained in the Silverlight engine. That is the only thing we are able to see in Silverlight.  You can make a grid scroll using the ScrollViewer element with code like this:

ScrollViewer scroller = myLB.Find.ByType<ScrollViewer>();

scroller.InvokeMethod("ScrollToVerticalOffset", scrollPos);

Greetings,
Cody
the Telerik team
Check out the Test Studio roadmap to find out more about the new performance testing functionality coming in our R2 2011 release this September!

Have you looked at the new Online User Guide for Telerik Test Studio?
0
sivaraj
Top achievements
Rank 1
answered on 11 Aug 2011, 01:29 PM
What about the exception ?
0
Cody
Telerik team
answered on 11 Aug 2011, 05:13 PM
Hello Sivaraj,

I need more details about the exception you are getting. Which line of code is throwing the exception? Can you provide the complete stack trace?

Greetings,
Cody
the Telerik team
Vote for Telerik Test Studio at the Annual Automation Honors Voting!
0
emma
Top achievements
Rank 1
answered on 02 Sep 2011, 08:22 AM
We have silverlight application having quite a few datagrid to display data in database.  
Is it possible to get total number of rows (including not visible rows) in datagrid in silverlight application?
There is a property of selectedIndex of datagrid...is there a way to find out the index of a dataGridRow?
Thanks a lot.
0
Cody
Telerik team
answered on 08 Sep 2011, 08:53 PM
Hello Emma,

I am sorry but we don't currently have a direct method for discovering how many rows a Silverlight DataGrid contains. The technical problem is that a DataGrid is normally bound to an "ItemsSource" object which is a collection of anything. Since we have no way of knowing what this object is, we have no method of discovering how many items are in the collection.

Maybe your developers can add a hidden field/element somewhere in the UI which contains the count you need?

If you have a GridViewRow you can get at it's index like this:

row.Index;


Regards,
Cody
the Telerik team
Vote for Telerik Test Studio at the Annual Automation Honors Voting!
0
emma
Top achievements
Rank 1
answered on 09 Sep 2011, 01:41 AM
Thanks very much for the quick response.  We will talk to the developers about the solution that you've suggested. 
Tags
General Discussions
Asked by
sivaraj
Top achievements
Rank 1
Answers by
Stoich
Telerik team
sivaraj
Top achievements
Rank 1
Cody
Telerik team
emma
Top achievements
Rank 1
Share this question
or