I’m trying to pass Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlDiv as an argument so I need to initialize and find the specific control I’m looking for in one line (if possible) but I’m struggling to figure that out. Normal initialization is done like so…
HtmlDiv htmlDiv = new HtmlDiv(htmlDocument) // where htmlDocument is of Microsoft.VisualStudio.TestTools.UITesting.UITestControl
htmlDiv.SearchProperties[HtmlDiv.PropertyNames.Id] = "header";
I’m trying to do something like this…
myFunction(new HtmlDiv(htmlDocument) {
SearchProperties[HtmlDiv.PropertyNames.Id] = "header"
});
I’m getting the error cannot resolve symbol 'SearchProperties' and Cannot initialize type 'Microsoft.VisualStudio.TestTools.UITesting.HtmlControls.HtmlDiv' with a collection initializer because it does not implement 'System.Collections.IEnumerable'.
Is there a way to make this work?
I couldn’t figure a way out to do this so I created a method in my HtmlDocument wrapper class that would return the found UITestControl.
and used like so…