2016-05-25 13 views
0

Ich verwende White Framework, um UI-Automatisierung in einer Windows Desktop-basierten Anwendung zu tun. Ich finde keine Möglichkeit, auf ein untergeordnetes Fenster zuzugreifen. UIAVerify zeigt die Eigenschaften des Fensters als:Zugriff auf ein untergeordnetes Fenster in einem Hauptfenster in White Framework

Unten ist der Code als Referenz:

public class Program 
{ 
    Application app = Application.Launch("Path to my application"); 

    public Program() 
    { 
     //Getting the main window 
     Window MainWindow = app.GetWindow("MainForm", InitializeOption.NoCache); 
     MainWindow.WaitWhileBusy(); 
     **//Here I wanna get the child window so that I can access controls on that window. Below is the code for getting child windows controls** 
     //Getting to the Firm box 
     TextBox firm = Childwindow.Get<TextBox>(SearchCriteria.ByAutomationId("1313948")); 
     //setting value for firm 
     firm.SetValue("FIRM2"); 
     //getting StaffID text box 
     TextBox StaffID = Childwindow.Get<TextBox>(SearchCriteria.ByAutomationId("723272")); 
     StaffID.SetValue("Staff"); 

     Button Ok = Childwindow.Get <Button>(SearchCriteria.ByAutomationId("_okB[enter image description here][1]utton")); 
     Ok.Click(); 
    } 

Antwort

0

Verwenden TreeScope.Children die unmittelbar untergeordneten Elemente des Desktops zuzugreifen:

AutomationElement rootElement = AutomationElement.RootElement; 
    var winCollection = rootElement.FindAll(TreeScope.Children, Condition.TrueCondition); 

    foreach (AutomationElement element in winCollection) 
     Console.WriteLine(element.Current.Name);