A . automated operation of the interface
. Ui Automation Testing
. Software plug -in
Two . Win32 Basic Knowledge
all elements in A.win32 are windows, and there is a parent-child relationship between windows. The entire desktop is a "root window".
B. process:
Get the process object based on the process id processes = Process.getprocessbyid (processId);
Start a process: process process= Process.Start (exe path );
Kills a process . Kill ()
Three . Uiautonation Foundation
1, need to add to uiautomationclient, uiautomationprovider, references to uiautomationtypes
2,automationelement.rootelement is the window root element
Automationelement.fromhandle (INTPTR hwnd) gets the AutomationElement object from the window handle .
3. Traverse:
Mainelement.findall (Treescope.descendants,
New PropertyCondition (Automationelement.classnameproperty, "Tlabelededit"));
The Treescope.descendants represents recursion from all descendant elements recursively, and if it is found from a direct child node, the Treescope.children is used .
Condition is a filter condition that can be looked up based on the class name, or if the query condition is not specified, use condition.true Condition.
FindFirst was the first one to find out.
4, click the button, set the text, read the text using Pattern to achieve. Not all Pattern Support
1) Set the value of the control
ValuePattern
ValuePattern = (ValuePattern) element. Getcurrentpattern (Valuepattern.pattern);
Valuepattern.setvalue ("rupeng.com");
2) Get the value of the text control
TextPattern
ValuePattern = (TextPattern) element. Getcurrentpattern (Textpattern.pattern);
String v= ValuePattern.DocumentRange.GetText (-1);
3) invoking the control, such as clicking the button
var Clickpattern = (Invokepattern) element. Getcurrentpattern (Invokepattern.pattern);
Clickpattern.invoke ();
UIAutomation Learning Primer