Hi.
I would like to be able to simulate a user inputting values into the cells of a radGridView in a WPF application.
I have access to the grid itself within the coded step and can read the contents of each cell (view GridViewCell.TextBlockContent property).
What I would to do is set/input the text into the cell (as if the user had typed it in).
I want to do this in a coded step because the number of rows will vary and I want to input a value into each row.
I have converted a recorded input step to code and can see that it uses TextBox.SetText(), but I can't see how I can do this for a cell?
Any help would be appreciated.
Thanks,
Mike.
I would like to be able to simulate a user inputting values into the cells of a radGridView in a WPF application.
I have access to the grid itself within the coded step and can read the contents of each cell (view GridViewCell.TextBlockContent property).
What I would to do is set/input the text into the cell (as if the user had typed it in).
I want to do this in a coded step because the number of rows will vary and I want to input a value into each row.
I have converted a recorded input step to code and can see that it uses TextBox.SetText(), but I can't see how I can do this for a cell?
Any help would be appreciated.
Thanks,
Mike.
4 Answers, 1 is accepted
0
Hello Mike,
Let me do some clarification on the quote bellow:
"I have converted a recorded input step to code and can see that it uses TextBox.SetText(), but I can't see how I can do this for a cell?"
In a RadGridView, what you're editing is not actually the grid cell itself, but the textblock that has been placed within that cell. Keep in mind that a grid cell may contain virtually anything, text, an icon, a link, another grid, and so on. The content of the cell changes radically between when the cell is in view mode versus editing mode. Examine the two attached screen shots, "Cell in view mode" and "Cell in edit mode". Notice when in view mode you have a TextBlock that is displaying the text. Versus in edit mode the content of the cell is changed radically. You now have a TextBoxView which is an editable type of UI element.
That is why when you convert the recorded step to code you see TextBox.SetText() method. So you can use the code generated by Test Studio.
Regards,
Ivaylo
Telerik
Let me do some clarification on the quote bellow:
"I have converted a recorded input step to code and can see that it uses TextBox.SetText(), but I can't see how I can do this for a cell?"
In a RadGridView, what you're editing is not actually the grid cell itself, but the textblock that has been placed within that cell. Keep in mind that a grid cell may contain virtually anything, text, an icon, a link, another grid, and so on. The content of the cell changes radically between when the cell is in view mode versus editing mode. Examine the two attached screen shots, "Cell in view mode" and "Cell in edit mode". Notice when in view mode you have a TextBlock that is displaying the text. Versus in edit mode the content of the cell is changed radically. You now have a TextBoxView which is an editable type of UI element.
That is why when you convert the recorded step to code you see TextBox.SetText() method. So you can use the code generated by Test Studio.
Regards,
Ivaylo
Telerik
0
Mike
Top achievements
Rank 1
answered on 06 Feb 2015, 01:28 PM
Hi Ivaylo
Thanks for your response.
What I would like to do is iterate over the grid rows and "input" a value into each cell.
Could you provide some sample code to do this please?
Thanks,
Mike.
Thanks for your response.
What I would like to do is iterate over the grid rows and "input" a value into each cell.
Could you provide some sample code to do this please?
Thanks,
Mike.
0
Madhu
Top achievements
Rank 1
answered on 09 Feb 2015, 09:43 PM
Hi Ivaylo,
I'm also in same situation with my silverlight application. Trying to enter some numbers in 'GridViewCell'. But no luck. See attachment.
Please provide a solution asap.
Thanks,
Madhu.
I'm also in same situation with my silverlight application. Trying to enter some numbers in 'GridViewCell'. But no luck. See attachment.
Please provide a solution asap.
Thanks,
Madhu.
0
Hello Mike,
Here is a complete working example of selecting and editing cells in a Silverlight RadGridView. If you're dealing with a WPF application, the approach is virtually the same. The only difference is you launch the application instead of a browser, and you don't navigate to a website.
@Madhu, this is answering your question as well, if you continue experiencing issues, please submit your own ticket/thread instead of interjecting to an existing one.
Regards,
Ivaylo
Telerik
Here is a complete working example of selecting and editing cells in a Silverlight RadGridView. If you're dealing with a WPF application, the approach is virtually the same. The only difference is you launch the application instead of a browser, and you don't navigate to a website.
[TestMethod]
public
void
SilverlightDataGrid()
{
Manager.Settings.Web.EnableSilverlight =
true
;
Manager.LaunchNewBrowser();
ActiveBrowser.NavigateTo(
"http://demos.telerik.com/silverlight/#GridView/DataSources"
);
// Wait for the app to finish loading
System.Threading.Thread.Sleep(5000);
SilverlightApp sl_app = ActiveBrowser.SilverlightApps()[0];
RadGridView rgv = sl_app.Find.ByAutomationId<RadGridView>(
"RadGridView1"
);
IList<GridViewCell> gridCells = rgv.Rows[0].Cells;
foreach
(GridViewCell cell
in
gridCells)
{
cell.User.Click();
Manager.Desktop.KeyBoard.TypeText(
"ABC 123"
);
System.Threading.Thread.Sleep(500);
}
System.Threading.Thread.Sleep(5000);
}
@Madhu, this is answering your question as well, if you continue experiencing issues, please submit your own ticket/thread instead of interjecting to an existing one.
Regards,
Ivaylo
Telerik