29 Answers, 1 is accepted
0
Hi Svetlana,
Thanks for the question and based on yout previous posts, I am assuming you are trying to search rows within a RadGrid like this demo page.
If so, please try the following coded solution:
- Highlight and add the grid to your test project (see attached screenshot also for reference):
- The grid will be added to your project and should look like this in the Elements Explorer Window:
All Pages -> ASPNETGridDemo -> RadGrid1Div
- You can then find the cell you want by content, then get the row as the cell's parent. Please see the following coded step example based on the demo page:
The code finds the first row in the demo page by the cell content 'Chai', finds it's parent row, then int r is the row index. There are other properties in
Please let us know if you have any questions on the above.
Best wishes,
Nelson Sin
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.
Thanks for the question and based on yout previous posts, I am assuming you are trying to search rows within a RadGrid like this demo page.
If so, please try the following coded solution:
- Highlight and add the grid to your test project (see attached screenshot also for reference):
- The grid will be added to your project and should look like this in the Elements Explorer Window:
All Pages -> ASPNETGridDemo -> RadGrid1Div
- You can then find the cell you want by content, then get the row as the cell's parent. Please see the following coded step example based on the demo page:
//Add your test methods here...
[CodedStep(
"MyCustom Step Description"
)]
public
void
MyCustomStep()
{
GridDataCell c = Pages.ASPNETGridDemo.RadGrid1Div.Find.ByExpression<GridDataCell>(
"TextContent=Chai"
);
GridDataItem i = c.Parent<GridDataItem>();
int
r = i.RowIndex;
}
The code finds the first row in the demo page by the cell content 'Chai', finds it's parent row, then int r is the row index. There are other properties in
GridDataItem i
you can use as well.Please let us know if you have any questions on the above.
Best wishes,
Nelson Sin
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
Svetlana
Top achievements
Rank 1
answered on 08 Jun 2010, 11:40 AM
Hi Nelson,
1) I've got an error on execution of "
Error text:
InnerException:
System.NullReferenceException: Object reference not set to an instance of an object.
at SFT.New_Test3.New_Test3_CodedStep() in c:\Users\Documents\WebUI Test Studio Projects\SFT\New Test3.aii.cs:line 85
I tried to replace
2) And seems that
Regards,
Svetlana
1) I've got an error on execution of "
GridDataItem i = c.Parent<GridDataItem>();"
string.Error text:
InnerException:
System.NullReferenceException: Object reference not set to an instance of an object.
at SFT.New_Test3.New_Test3_CodedStep() in c:\Users\Documents\WebUI Test Studio Projects\SFT\New Test3.aii.cs:line 85
I tried to replace
<GridDataItem>
with <Telerik.WebAii.Controls.Html.GridDataItem> but the result the same :(2) And seems that
"
Find.ByExpression<GridDataCell>" expression does not work
because I haven't got the error when not matching value was entered.Regards,
Svetlana
0
Hello again Svetlana,
1) So the example page has that particular implementation and example code was based on it's Dom. Please check your page's implementation and the Dom Explorer to see what kind of html control you would need in your test code.
For example, you can also use the control
2) I'm not exactly sure exactly what you mean with your question, but if the GridDataCell is not found by TextContent, then you would need to handle a null reference exception.
Thanks,
Nelson
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.
1) So the example page has that particular implementation and example code was based on it's Dom. Please check your page's implementation and the Dom Explorer to see what kind of html control you would need in your test code.
For example, you can also use the control
HtmlTableRow r = c.Parent<HtmlTableRow>();
since the html tag is also a <TR>2) I'm not exactly sure exactly what you mean with your question, but if the GridDataCell is not found by TextContent, then you would need to handle a null reference exception.
Thanks,
Nelson
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
Svetlana
Top achievements
Rank 1
answered on 09 Jun 2010, 09:17 AM
Hi Nelson,
When I get 'RowIndex', how can I refer to some sell in the row?
E.g for the example page http://demos.telerik.com/aspnet-ajax/grid/examples/performance/linq/defaultcs.aspx after the coded step
we get r=2. How can I refer to 'Quantity per unit' column to ensure that the value is '10 boxes x 20 bags'?
Thanks,
Svetlana
When I get 'RowIndex', how can I refer to some sell in the row?
E.g for the example page http://demos.telerik.com/aspnet-ajax/grid/examples/performance/linq/defaultcs.aspx after the coded step
[CodedStep(
"MyCustom Step Description"
)]
public
void
MyCustomStep()
{
GridDataCell
c =
Pages.ASPNETGridDemo.RadGrid1Div.Find.ByExpression<GridDataCell>(
"TextContent=Chai"
);
GridDataItem
i = c.Parent<GridDataItem>();
int
r
= i.RowIndex;
}
we get r=2. How can I refer to 'Quantity per unit' column to ensure that the value is '10 boxes x 20 bags'?
Thanks,
Svetlana
0
Hello Svetlana,
Since you already have a reference to the row, you simply need to access its DataCells collection and get the desired cell:
Hope this helps.
Greetings,
Pavel
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.
Since you already have a reference to the row, you simply need to access its DataCells collection and get the desired cell:
GridDataCell fourthCell = i.DataCells[3];
Assert.AreEqual(
"10 boxes x 20 bags"
, fourthCell.TextContent,
"verification failed"
);
Hope this helps.
Greetings,
Pavel
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
Svetlana
Top achievements
Rank 1
answered on 09 Jun 2010, 01:16 PM
Hi Pavel,
Thank you for the help. Could you, please, tell how can I refer to span element within the sell?
Source code:
<tr id="ctl00_StatusGrid_ctl00__0" class="rgRow">
<td class="rgGroupCol">
</td>
<td class="NoHorizontalPadding">
<span title="Not present today" class="StNotPre"></span>
</td>
Regards,
Svetlana
Thank you for the help. Could you, please, tell how can I refer to span element within the sell?
Source code:
<tr id="ctl00_StatusGrid_ctl00__0" class="rgRow">
<td class="rgGroupCol">
</td>
<td class="NoHorizontalPadding">
<span title="Not present today" class="StNotPre"></span>
</td>
Regards,
Svetlana
0
Hello Svetlana,
What is it you want to do with the span element?
Assuming 'c' represents the DataGridCell that contains the span element (i.e. just this portion of your sample source code):
then you can locate the span element with this like of code:
Greetings,
Cody
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.
What is it you want to do with the span element?
Assuming 'c' represents the DataGridCell that contains the span element (i.e. just this portion of your sample source code):
<
td
class
=
"NoHorizontalPadding"
>
<
span
title
=
"Not present today"
class
=
"StNotPre"
></
span
>
</
td
>
then you can locate the span element with this like of code:
HtmlSpan mySpan = c.Find.ByExpression<HtmlSpan>(
"title=Not present today"
);
Greetings,
Cody
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
Svetlana
Top achievements
Rank 1
answered on 10 Jun 2010, 08:30 AM
Thank you, Cody
Regards,
Svetlana
Regards,
Svetlana
0
Svetlana
Top achievements
Rank 1
answered on 13 Jul 2010, 04:08 PM
Hello Telerik team,
I have one more question on Searching in RadGrid.
There is the following content in Grid data cell:
<td valign="middle">
<strong>New</strong>
<br>
17/06/2010 to 18/06/2010
</td>
How to find the cell in grid by value in "strong" tag?
Seems that the value does not included in "TextContent", because
GridDiv.Find.ByExpression<Telerik.WebAii.Controls.Html.GridDataCell>("TextContent=New 17/06/2010 to 18/06/2010");
- returns error.
Could you, please, write correct expression?
Regards,
Svetlana
I have one more question on Searching in RadGrid.
There is the following content in Grid data cell:
<td valign="middle">
<strong>New</strong>
<br>
17/06/2010 to 18/06/2010
</td>
How to find the cell in grid by value in "strong" tag?
Seems that the value does not included in "TextContent", because
GridDiv.Find.ByExpression<Telerik.WebAii.Controls.Html.GridDataCell>("TextContent=New 17/06/2010 to 18/06/2010");
- returns error.
Could you, please, write correct expression?
Regards,
Svetlana
0
Accepted
Hi Svetlana,
You are very close to the right coded solution. You need to make two modifications:
Alternatively you could just remove the "New " part (including the space) from your current line of code. Then TextContent would match the date string of your sample.
Greetings,
Cody
the Telerik team
You are very close to the right coded solution. You need to make two modifications:
- Use InnerText instead of TextContent. There is a subtle but important difference between the two. TextContent looks only at the text at the same level. Whereas InnerText is recursive. it will be all text combined for the current element and all the text contained in subelements. In your example "New" is the InnerText for just the <strong> element and "17/06/2010 to 18/06/2010" is the TextContent for the <td> element. InnerText is the two concatenated together i.e. "New17/06/2010 to 18/06/2010".
- Note that InnerText doesn't have a space between "New" and the date. Thus your second change would be to remove that space resulting in this line of code:
GridDiv.Find.ByExpression<HtmlTableCell>(
"InnerText=New17/06/2010 to 18/06/2010"
);
Alternatively you could just remove the "New " part (including the space) from your current line of code. Then TextContent would match the date string of your sample.
Greetings,
Cody
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
Svetlana
Top achievements
Rank 1
answered on 15 Jul 2010, 01:18 PM
Thank you Cody!
0
Nataly
Top achievements
Rank 1
answered on 16 Aug 2010, 04:59 PM
Hello,
Is it possible to modify searching in the grid and add wait time to perform the action several times till some row isn't found yet? As it may be done in recorded steps (e.g. "Verify the element is visible" -> "Wait for element is visible")
Thank you in advance.
Is it possible to modify searching in the grid and add wait time to perform the action several times till some row isn't found yet? As it may be done in recorded steps (e.g. "Verify the element is visible" -> "Wait for element is visible")
Thank you in advance.
0
Hi Nataly,
Is it the actual element you want to verify, or the text contained in a specific grid item? If you want to assert a row has been added correctly to the grid you can use the items count verification. This shows the number of items in the current page. The other option is to verify the number of total items via the pager text. Screenshots are attached to illustrate both cases. Let me know if that helps.
Sincerely yours,
Pavel
the Telerik team
Is it the actual element you want to verify, or the text contained in a specific grid item? If you want to assert a row has been added correctly to the grid you can use the items count verification. This shows the number of items in the current page. The other option is to verify the number of total items via the pager text. Screenshots are attached to illustrate both cases. Let me know if that helps.
Sincerely yours,
Pavel
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
Nataly
Top achievements
Rank 1
answered on 17 Aug 2010, 10:29 AM
Hi Pavel,
I need to find grid item by content. The content is stored in string variable. This item is added on test execution but I don't want to use grid row's count because real user may add a row while my test is being executed. So I just need to perform 'wait' till grid item with some content appears on the page.
Thank you.
I need to find grid item by content. The content is stored in string variable. This item is added on test execution but I don't want to use grid row's count because real user may add a row while my test is being executed. So I just need to perform 'wait' till grid item with some content appears on the page.
Thank you.
0
Hi Nataly,
In that case I think you need to use Data cell text verification. Note that in order for it to search for a text in a specific cell you need to modify your Find logic settings so that the tag index has higher priority than text content. Otherwise the location of the element is done by its content which does not guarantee that the cell is in specific place in the Grid.
I hope this helps.
Regards,
Pavel
the Telerik team
In that case I think you need to use Data cell text verification. Note that in order for it to search for a text in a specific cell you need to modify your Find logic settings so that the tag index has higher priority than text content. Otherwise the location of the element is done by its content which does not guarantee that the cell is in specific place in the Grid.
I hope this helps.
Regards,
Pavel
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
Nataly
Top achievements
Rank 1
answered on 17 Aug 2010, 11:17 AM
Thank you Pavel.
Unfortunately, cell's index is unknown and will differ on each test execution. So I can't use this solution. Is there another one?
Regards,
Nataly
Unfortunately, cell's index is unknown and will differ on each test execution. So I can't use this solution. Is there another one?
Regards,
Nataly
0
Hi Nataly,
If the cell index differs, you can simply use the default behavior which locates the cell by its text. Let me know if this is acceptable solution.
Greetings,
Pavel
the Telerik team
If the cell index differs, you can simply use the default behavior which locates the cell by its text. Let me know if this is acceptable solution.
Greetings,
Pavel
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
Nataly
Top achievements
Rank 1
answered on 17 Aug 2010, 12:22 PM
Thank you Pavel.
Yes, it is acceptable, but I shall perform 'wait' action till the row appears in grid.
How can I perform such wait?
Regards,
Nataly
Yes, it is acceptable, but I shall perform 'wait' action till the row appears in grid.
How can I perform such wait?
Regards,
Nataly
0
Hi Nataly,
Each verification in WebUI Test Studio has its "wait for" version. In the datacelltext.jpg screenshot attached previously you can see the "wait for" data cell text verifiaction of the Grid Item. Furthermore you can always convert a regular verification to a "wait", by right clicking on the step in question and selecting "Set as Wait".
Best wishes,
Pavel
the Telerik team
Each verification in WebUI Test Studio has its "wait for" version. In the datacelltext.jpg screenshot attached previously you can see the "wait for" data cell text verifiaction of the Grid Item. Furthermore you can always convert a regular verification to a "wait", by right clicking on the step in question and selecting "Set as Wait".
Best wishes,
Pavel
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
Nataly
Top achievements
Rank 1
answered on 17 Aug 2010, 12:40 PM
Hi Pavel,
To add such step as on the screenshot I need to know row's index but the index is unknown beforehand. So seems that I can't use standard recorded step.
How can I perform 'wait' for cell appearing in the grid in coded step?
Thank you in advance.
To add such step as on the screenshot I need to know row's index but the index is unknown beforehand. So seems that I can't use standard recorded step.
How can I perform 'wait' for cell appearing in the grid in coded step?
Thank you in advance.
0
Hello Nataly,
As I explained previously, if you use the default Find logic, the verification illustrated in the screenshot will locate the cell by its text content, not its id or location in the table. Thus it should work wherever the item appears in the Grid.
Regards,
Pavel
the Telerik team
As I explained previously, if you use the default Find logic, the verification illustrated in the screenshot will locate the cell by its text content, not its id or location in the table. Thus it should work wherever the item appears in the Grid.
Regards,
Pavel
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
Nataly
Top achievements
Rank 1
answered on 17 Aug 2010, 02:16 PM
Hello Pavel,
I'm using default Find logic, but this step fails:
RadGridDataCell: cell [2,0] text verification failed.
Expected: 'ValueOnExecution', Comparison: 'Is', Actual: 'ValueOnCreation'.
Could you please tell how can I fix it?
Thank you in advance
I'm using default Find logic, but this step fails:
RadGridDataCell: cell [2,0] text verification failed.
Expected: 'ValueOnExecution', Comparison: 'Is', Actual: 'ValueOnCreation'.
Could you please tell how can I fix it?
Thank you in advance
0
Hi Nataly,
You can edit the element's find expression via elements explorer. I am attaching screenshots for illustration. Your find expression needs to be similar to the one in the attached file. Let me know if that helps.
Sincerely yours,
Pavel
the Telerik team
You can edit the element's find expression via elements explorer. I am attaching screenshots for illustration. Your find expression needs to be similar to the one in the attached file. Let me know if that helps.
Sincerely yours,
Pavel
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
Nataly
Top achievements
Rank 1
answered on 18 Aug 2010, 08:37 AM
Hi Pavel,
In my case "text content" and "row index" will be different on each test execution. I can't specify them in element's 'find expression' directly isn't it?
Is there the possibility to change element's 'find expression' at runtime?
Thank you
In my case "text content" and "row index" will be different on each test execution. I can't specify them in element's 'find expression' directly isn't it?
Is there the possibility to change element's 'find expression' at runtime?
Thank you
0
Hi Nataly,
I am sorry but it seems I have misunderstood you. Now to clarify your requirement, you need to verify a Grid Item by its content, however the content may be different on each execution, and the location of the item may also vary, is that correct?
If the value is variable, but there is a way to extract it (I am not familiar with your exact scenario, but I am guessing there should be some way to do that), you can locate the element with code in a similar way:
Note that in order to ensure that the Grid is updated before executing this step it is recommended to add a step that verifies that the control is not longer in insert mode. A screenshot is attached for illustration. This should prevent any synchronization issues where the cell is not yet present on the page.
Let me know if I am missing something else.
Greetings,
Pavel
the Telerik team
I am sorry but it seems I have misunderstood you. Now to clarify your requirement, you need to verify a Grid Item by its content, however the content may be different on each execution, and the location of the item may also vary, is that correct?
If the value is variable, but there is a way to extract it (I am not familiar with your exact scenario, but I am guessing there should be some way to do that), you can locate the element with code in a similar way:
[CodedStep(@
"RadGridDataCell(''): cell content verification "
)]
public
void
VerifyGridCellContent()
{
string
cellContent;
//logic to get the cell content here and assign it to the sting variable
GridDataCell myCell = Find.ByContent<GridDataCell>(cellContent);
Assert.IsTrue(myCell.CellText == cellContent);
}
Note that in order to ensure that the Grid is updated before executing this step it is recommended to add a step that verifies that the control is not longer in insert mode. A screenshot is attached for illustration. This should prevent any synchronization issues where the cell is not yet present on the page.
Let me know if I am missing something else.
Greetings,
Pavel
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
Nataly
Top achievements
Rank 1
answered on 20 Aug 2010, 01:06 PM
Hello Pavel,
Thank you for the answer. I have one more question: it's strange but I have not "Wait: radGridTable: is not in insert mode" quick task in the list. Could you please tell me what should I do to get it?
Regards,
Nataly
Thank you for the answer. I have one more question: it's strange but I have not "Wait: radGridTable: is not in insert mode" quick task in the list. Could you please tell me what should I do to get it?
Regards,
Nataly
0
Hello Nataly,
This quick task is visible when you have CommandItem displayed for the respective TableView. You can use the following code to make a similar verification:
Sincerely yours,
Pavel
the Telerik team
This quick task is visible when you have CommandItem displayed for the respective TableView. You can use the following code to make a similar verification:
RadGrid grid = Find.ById<RadGrid
>(
"RadGrid1"
);
Wait.For<RadGrid>(myGrid => !myGrid.MasterTable.IsItemInserted, grid, 3000);
Sincerely yours,
Pavel
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
Lobna
Top achievements
Rank 1
answered on 27 Oct 2013, 01:05 PM
I have RadGrid having multiple Rows and I need to filter the data. I use 'allowfiltering' property, but I want to ask is there a way to make filtering automatic, without pressing enter or remove the cursor from the filter textbox?
Thanks,
Thanks,
0
Hello Lobna,
Boyan Boev
Telerik
Is this somehow connected to Test Studio and automation testing? If so please give us some more detailed information and I will be glad to help you.
If it is connected to the Silverlight RadGrid control please visit this forum. If it is regarding .NET ASP controls please visit this one.
Thank you for contacting us.
Boyan Boev
Telerik
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
Test Studio Trainings