[ codedui test adding a record causes duplicate record error on playback ]
Sooo, I am new to codedui so I may need some hand holding. I have a web application. It is like a customer service app. So I add a record, in this case I am adding an institution and there are 5 required fields, 2 of the fields are ID numbers. When I playback the recording, I will error out on the first ID becasue it is trying to add an inst with an existing ID (the same will happen on the second ID if I bypass the first.
Unfortunately, I cannot delete the institution.
So can I add code that will increase the Institution ID each time the test runs? If so, what is the code I need and where do I add it?
This is from the CodedUITest.cs
[TestMethod]
public void CodedUITestMethod1()
{
// Add a new Institution
this.UIMap.NavToInst_and_Add_Inst();
}
***This is the the definition in the UIMap.Designer.cs***
// Type '99999' in '* Institution ID:' text box
uIInstitutionIDEdit.Text = this.NavToInst_and_Add_InstParams.UIInstitutionIDEditText;
***And when I go to definition from 'UIInstitutionIDEditText' I get this***
/// <summary>
/// Type '99999' in '* Institution ID:' text box
/// </summary>
public string UIInstitutionIDEditText = "99999";
I hope I have covered everything, thanks so much for any help you can provide. I have searched for an answer but haven't had any luck. I am also not a coder.
Thanks again!
Answer 1
What ever API your using to add an entry you'll need to check what the biggest number currently used is and assign it to the variable you intend to let CodedUI
to assign to the text box.
some liberty used to to illustrate
var highestUsedId = // your production code for looking up highest ID
UIMap.UIWindow.UIDocument.UIInstitutionIDEditText = (highestUsedId + 1).ToString();
UIMap.NavToInst_and_Add_Inst();