C# Coded UI testing - enter text into a javascript window.prompt text box

Viewed 729

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 = "bill@microsoft.com";

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?

1 Answers
Related