简体   繁体   中英

Can't find WinWindow by property “Name”

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 :)

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM