Reputation: 3
I've got the following problem:
I try to create a Coded UI Test in Visual Studio 2015 Enterprise Edition without using the Generator. I want to achieve the very simple thing of pressing a button and looking at the results.
My Forms are not directly WinForms, but it's the basis of them.
Here's what I'm trying to do:
public void CodedUITestTestMethod()
{
//1. Step: Log into the program
LogIntoProgram();
}
private void LogIntoProgram()
{
// Find the Login-Window
WinWindow loginWindow = GetWindowByTitle("Program - Login");
[...]
}
private WinWindow GetWindowByName(string title, UITestControl parent = null)
{
// If the Window has a parent, assign it to the window
WinWindow result = parent == null ? new WinWindow() : new WinWindow(parent);
result.SearchProperties.Add(WinWindow.PropertyNames.Name, title);
result.Find();
return result;
}
The [...] section is where I want to press the button. The problem occurs before that though, as I can't even find the window I'm looking for. It repeatedly throws the UITestControlNotFound exception, no matter if I use the Title or the Classname of the Form.
I got the feeling that I am missing a very major point, but I can't figure out which one.
Thanks for the help in advance,
SchwarzSkills :)
Upvotes: 0
Views: 242
Reputation: 1811
Start your application and pass it into the WinWindow
var app = ApplicationUnderTest.Launch("C:\\Windows\\System32\\myProgram.exe"
, "%windir%\\System32\\myProgram.exe");
WinWindow loginWindow = GetWindowByTitle("Program - Login", app);
Upvotes: 1