I'm running coded UI tests in Visual Studio Enterprise 2017.
My webpage under test has a javascript popup asking for an e-mail address to be entered. I can locate the confirmationPopup (highlight is drawn correctly), and I can click buttons within it, such as the cancel.
confirmationPopup = new WinWindow();
confirmationPopup.SearchProperties.Add(WinWindow.PropertyNames.ControlType, "Dialog");
confirmationPopup.SearchProperties.Add(WinWindow.PropertyNames.ClassName, "#32770");
confirmationPopup.TechnologyName = "MSAA";
confirmationPopup.Find();
confirmationPopup.DrawHighlight();
var cancelButton = new WinButton(confirmationPopup);
cancelButton.SearchProperties.Add(WinButton.PropertyNames.Name, "Cancel");
Mouse.Click(cancelButton);
What I am struggling to do is enter text in the popup's input box:
var textInput = new WinEdit(confirmationPopup);
textInput.SearchProperties.Add(WinEdit.PropertyNames.ClassName, "Edit");
textInput.TechnologyName = "MSAA";
textInput.DrawHighlight();
textInput.Text = "[email protected]";
The highlight is drawn around the correct control, but the textInput.Text= line gives an error Additional information: SetProperty of "Text" is not supported on control type: Window
Any ideas what I'm doing wrong?
Here is an example of interacting with javascript prompt window.
// go to a public site which has a prompt
var window = BrowserWindow.Launch("http://www.javascriptkit.com/javatutors/alert2.shtml");
var contentDiv = new HtmlDiv(window);
contentDiv.SearchProperties.Add(HtmlDiv.PropertyNames.Id, "contentcolumn", PropertyExpressionOperator.EqualTo);
var promptButton = new HtmlInputButton(contentDiv);
promptButton.SearchProperties.Add(HtmlInputButton.PropertyNames.ControlDefinition, "name=\"B4\"", PropertyExpressionOperator.Contains);
promptButton.SetFocus();
Keyboard.SendKeys("{ENTER}");
// now the prompt is showing, find it and set text
var promptWindow = new WinWindow();
promptWindow.SearchProperties.Add(WinWindow.PropertyNames.ControlType, "Dialog");
promptWindow.SearchProperties.Add(WinWindow.PropertyNames.ClassName, "#32770");
promptWindow.DrawHighlight();
var middleWindow = new WinWindow(promptWindow);
middleWindow.DrawHighlight();
var inputBox = new WinEdit(middleWindow);
inputBox.DrawHighlight();
inputBox.Text = "Hello world!";
When using the inspect feature of coded ui, I see there is a middle window. Using it or not, I am able to find the edit.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With