Quantcast
Viewing all articles
Browse latest Browse all 585

UIAutomation stackoverflow exception rootelement.findfirst


I am trying to use System.Windows.Automation to automate GUI regression testing. In the constructor of my test object, I launch the application and locate it in the tree with AutomationElement.RootElement.FindFirst, and I limit the scope of the search to children. I getting a stackoverflowexception every time I run my test just to launch the application and locate the form. Any help wold be greatly appreciated. My constructor:

<!-- language: c# -->
public GuiTest(string inFormName, string inExecutable, Dictionary<string, ControlTypes> inElements)
{
    //Start the GUI
    myProcess = Process.Start(inExecutable);

    //We have to give the application time to fire up
    int count = 0;
    do
    {
        //Get the root element of the GUI
        myParentElement = AutomationElement.RootElement.FindFirst
            (TreeScope.Children, new PropertyCondition(AutomationElement.NameProperty, inFormName));
    }while(myParentElement == null && count < 50);

    if (myParentElement == null)
    {
        throw new InvalidOperationException("Could not find form " + inFormName);
    }

    //Get the buttons and stuff
    LoadElements(inElements);    
}




Viewing all articles
Browse latest Browse all 585

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>