Forum Discussion
Here is a sample function to find and click a control.
[Control need to be search] = pProcess.FindChild( [Property of the control] , [Value of the control], [How Deep to Search])
EX: var btnLogIn = pProcess.FindChild( "ControlText" , "Log In", 10)
full example:
function ClickMenuDrawer(device, caption)
{
var status = false;
var props = "mContentDescription";
var values = caption;//"open drawer menu";
var searchControl;
if(Mobile.Device(device).Exists)
{
//Check The app existed or not
if(Mobile.Device(device).Process(app package).Exists)
{
var pProcess = Mobile.Device(device).Process(app package));
pProcess.Refresh();
var btnClick;
//Search the button
searchControl = pProcess.FindChild( props , values,10)
if(searchControl.Exists && searchControl.VisibleOnScreen)
{
//Click the button
btnClick = searchControl;
btnClick.Click();
Mobile.Device(device).Refresh();
status = true;
}
else
{
Log.Error("ClickMenuDrawer: FAIL! The button not found or invisible!");
}
}
else
{
Log.Error("ClickMenuDrawer: FAIL! The App is not installed or not an instrumented app.");
}
}
else
{
Log.Error("ClickMenuDrawer: FAIL! Device Not Found.");
}
return status;
}
Related Content
- 8 years ago
- 11 years ago