After working on the Object repository framework in Codedui, there are few more modifications done for the same, which would be bit more simple than earlier.
we follow the same steps till 3rd step as mentioned in the Object repository framework in Codedui, and the generic functions which are defined in the earlier one would vary.
Step 4:
Instead of going with different functions as mentioned in the before framework, we can go with a single function which can do every action we needed. However i thought of having 3functions which would be helpful
Functions in earlier framework
we follow the same steps till 3rd step as mentioned in the Object repository framework in Codedui, and the generic functions which are defined in the earlier one would vary.
Step 4:
Instead of going with different functions as mentioned in the before framework, we can go with a single function which can do every action we needed. However i thought of having 3functions which would be helpful
Functions in earlier framework
SetText(string ObjectName,string Value) - this function gets the object by the properites mentioned in csv file with the unique objectname and assignes the value in the TextBox
SelectListItem(string objectName,string value) - this function gets the object by the properties mentioned in csv file and slects the value in listbox
ClickButton(string ObjectName) - this function gets the object with objectname from csv file and clicks it
Updated Functions in this Framework
Object(string ObjectName) - this function returns the object by the properties mentioned in the CSV file
SetObject(string ObjectName, string value) - this function calls the Object function and for that particular object, depending upon the control type, the value is used.
- if control is an edit, then it enters the value in editbox
- if control is an Combobox, then it select the value item provided
- if control is an checkbox, if value is true - it checks, if false - it unchecks
- if control is an button, if value is true - it clicks the button
- ........
GetObject(string ObjectName, string PropertyName) - this function returns the value of the property you provide in the PropertyName which can be used for any verifications/assertions
These functions are to be written in the UIMap file
public static HtmlControl Object(string HtmlObjectName)
{
string objParentName = DataDictionary.excelread.dataKey[HtmlObjectName]["Parent"];
HtmlControl objParentObj = GetParentOf(objParentName);
HtmlControl obj;
obj = new HtmlControl(objParentObj);
string[] oPropNames = DataDictionary.excelread.dataKey[HtmlObjectName]["Name"].Split('|');
string[] oPropTypes = DataDictionary.excelread.dataKey[HtmlObjectName]["Value"].Split('|');
Assert.AreEqual(oPropNames.Length, oPropTypes.Length);
for (int i = 0; i < oPropNames.Length; i++)
{
obj.SearchProperties[oPropNames[i]] = oPropTypes[i];
}
obj.FindMatchingControls();
return obj;
}
public static void SetObject(string HtmlObjName, string value)
{
UITestControlCollection collection;
collection = Object(HtmlObjName);
string cntrltype = collection[0].GetProperty("ControlType").ToString();
switch (cntrltype)
{
case "Edit":
collection[0].SetProperty("Text", value);
// myEdit.Text = value;
break;
case "ComboBox":
collection[0].SetProperty("SelectedItem", value);
break;
case "CheckBox":
bool value1 = bool.Parse(value);
collection[0].SetProperty("Checked", value1);
break;
case "Button":
bool value2 = bool.Parse(value);
if (value2)
Mouse.Click(collection[0]);
break;
default:
break;
}
}
public static string GetObject(string HtmlObjName, string PropertyName)
{
UITestControlCollection collection;
collection = Object(HtmlObjName);
return collection[0];
}
Please let me know if any modifications or any changes which would help it more better.