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

Working with Custom Popup Edit Form

3 Answers 105 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jeffrey
Top achievements
Rank 1
Jeffrey asked on 13 Dec 2011, 06:10 PM
Hi all,

We are trying to use the automation testing framework in code to enter data into a custom edit popup form (like in this demo: http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/popupeditform/defaultcs.aspx
) to modify a row of data.  The problem we are having is that if we simply look for the Update button on the edit form and send it the Click() event then the form simply closes and does not actually trigger the RadGrid_UpdateCommand event handler.  This means the data never gets updated.

We have looked in the samples provided with the Testing Framework and there is an example with a in-place edit form, but none with a popup edit form.  Is there something special that we need to do with a custom edit popup form to get the row to update when we are done with the form?

Any help appreciated,

Thanks

3 Answers, 1 is accepted

Sort by
0
Pavel
Telerik team
answered on 14 Dec 2011, 12:52 PM
Hello Jeffrey,

I am not sure what the particular problem you have stumbled upon may be, however I have prepared a simple test using the page from our examples which you have referenced:
RadGrid grid = Find.ById<RadGrid>("RadGrid1");
 
GridDataItem firstRow = grid.MasteTable.DataItems[0];
GridDataCell firstRowThirdCell = firstRow.DataCells[2];
             
// assert initial value
Assert.IsTrue(firstRowThirdCell.CellText == "Chai", String.Format("Assert failed,  expected value {0}, actual {1}", "Chai", firstRowThirdCell.CellText));
 
HtmlAnchor firstRowEditButton = firstRow.Find.ById<HtmlAnchor>("~AutoGeneratedEditButton");
             
// put the item in edit mode
firstRowEditButton.Click();
Wait.For<GridDataItem>(myItem => myItem.Edited, firstRow, 5000);
                         
HtmlInputText productNameTbx = Find.ById<HtmlInputText>("~ctl05_ctl09");
productNameTbx.Value = "foo";
 
// update the item
GridEditForm editForm = Find.ById<GridEditForm>("~ctl05_ctl00");
editForm.Update();
 
Wait.For<GridDataItem>(myItem => !myItem.Edited, firstRow, 5000);
 
// verify grid is updated
Assert.IsTrue(firstRowThirdCell.CellText == "foo", String.Format("Assert failed,  expected value {0}, actual {1}", "foo", firstRowThirdCell.CellText));

You can use it as a reference and modify it to meet the requirements of your web page/test. Should any additional questions or difficulties arise, do not hesitate to let us know about them.

Greetings,
Pavel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jeffrey
Top achievements
Rank 1
answered on 14 Dec 2011, 07:38 PM
Thanks for your response.

That is very close to what we are trying to do.  I'm afraid I should have pointed you toward the custom edit form example: http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/usercontroleditform/defaultcs.aspx rather than the pop up.

Would the example you have be different if you were writing a test for a custom edit form, rather than a pop up form?  

Our particular problem is that when the custom edit form appears, and we tried modifying our code to look like what you have there.  When we call editForm.Update we get an error message on the order of "Edit form Failed! Cannot find button with update command" (not the exact wording, I don't have internet on my other workstation).

If, instead of callign Update, we find and click on the "Update" button itself, the RadGrid1_UpdateCommand handler never gets called.  In fact, no handlers on the RadGrid page get called.  It's all quite confusing.

On the update button we have on our custom form we have the Command="Update" attribute.

Can you offer any other help?  I will try to dummy up an example for you.
0
Pavel
Telerik team
answered on 15 Dec 2011, 08:56 AM
Hi Jeffrey,

In the case of a User Control Edit Form the approach is a bit different as we need to locate the update button manually (since the form is custom), in order to click it:

RadGrid grid = Find.ById<RadGrid>("RadGrid1");
 
GridDataItem firstRow = grid.MasterTable.DataItems[0];
GridDataCell firstRowThirdCell = firstRow.DataCells[2];
 
// assert initial value
Assert.IsTrue(firstRowThirdCell.CellText == "Nancy", String.Format("Assert failed,  expected value {0}, actual {1}", "Nancy", firstRowThirdCell.CellText));
 
HtmlAnchor firstRowEditButton = firstRow.Find.ById<HtmlAnchor>("~EditButton");
             
// put the item in edit mode
firstRowEditButton.Click();
Wait.For<GridDataItem>(myItem => myItem.Edited, firstRow, 5000);
 
HtmlInputText productNameTbx = Find.ById<HtmlInputText>("~EditFormControl_TextBox2");
productNameTbx.Value = "foo";
 
// update the item
GridEditForm editForm = Find.ById<HtmlTable>("Table2").Parent<GridEditForm>();
editForm.Find.ById<HtmlInputButton>("~btnUpdate").Click();
 
Wait.For<GridDataItem>(myItem => !myItem.Edited, firstRow, 5000);
 
// verify grid is updated
Assert.IsTrue(firstRowThirdCell.CellText == "foo", String.Format("Assert failed,  expected value {0}, actual {1}", "foo", firstRowThirdCell.CellText));

I used the above code with our user control edit form example and it is working as expected. Could you please try it and let me know if you can reproduce the problem you described? Alternatively, if that does not help, you can send us a live url of the page you are testing against (if available) so I can investigate further and pinpoint the exact cause for this unexpected behavior.

Best wishes,
Pavel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Jeffrey
Top achievements
Rank 1
Answers by
Pavel
Telerik team
Jeffrey
Top achievements
Rank 1
Share this question
or