Im trying to build a test case where i retrieve a list of data objects and populate it in a datagrid.
I want to verify (assert) that the 1st row has a field/column that StartsWith "ABC".
I can see that the generated code produces an element that basically has the field's exact display value (in this case it is "ABCDEFG").
Of course, when i run this test, it validates just fine because the generated element ("ABCDEFG") definitely startswith "ABC".
The problem is that the datagrid could be populated with dynamic data, so the field display could be something like "ABC-FOO" or even "XYZ" for instance.
In short the automated code that is generated seems to not behaving as i expect.
I am expecting to do a StartsWith assertion against the real-time field display, not a generated (hard-coded) string which i used to build the test with.
Am i doing something wrong here? Am i missing something critical? Or should i be abandoning Coded UI altogether?
Here is the generated element:
public HtmlLabel generatedLabel
{
get
{
if ((this.mUIgeneratedLabelLabel == null))
{
this.mUIgeneratedLabelLabel = new HtmlLabel(this);
#region Search Criteria
this.mUIgeneratedLabelLabel.SearchProperties[HtmlLabel.PropertyNames.Id] = "Control_42";
this.mUIgeneratedLabelLabel.SearchProperties[HtmlLabel.PropertyNames.Name] = null;
this.mUIgeneratedLabelLabel.SearchProperties[HtmlLabel.PropertyNames.LabelFor] = null;
this.mUIgeneratedLabelLabel.SearchProperties[HtmlLabel.PropertyNames.InnerText] = "ABCDEF-FOO";
this.mUIgeneratedLabelLabel.FilterProperties[HtmlLabel.PropertyNames.Class] = "field-control";
this.mUIgeneratedLabelLabel.FilterProperties[HtmlLabel.PropertyNames.ControlDefinition] = "class=\"field-control\" id=\"ControlB";
this.mUIgeneratedLabelLabel.FilterProperties[HtmlLabel.PropertyNames.TagInstance] = "24";
this.mUIgeneratedLabelLabel.WindowTitles.Add("MyTest");
#endregion
}
return this.mUgeneratedLabelLabel;
}
}
---- Updated ----
To explain what my confusion is: I've setup my StartsWith() assertion on some text ("ABCD") that has been retrieved dynamically. I created the asserttion to check if the text StartsWith "ABC". Now, when i look at the generated assertion code, i see that the assertion will always pass because the code is comparing the text's string literal ("ABCD") with the assertion check string literal ("ABC"). What I am looking for is to do the assertion check with whatever dynamic text is retrieved during the test run-time. Hope this makes it clear where im getting stuck.
... InnerText] = "ABCDEF-FOO";line and what to do about it? If yes then why not delete that entry from the search properties. See also stackoverflow.com/a/19703241/546871 - AdrianHHH