Before simulating touches on items of an action sheet control in an iOS application, you may need to check whether the item is enabled.
Getting the wItemEnabled Property
To check whether the action sheet’s item is enabled, use the wItemEnabled
property of the iOS ActionSheet
object that TestComplete associates with that control. If the item is enabled, the property returns True.
The following example demonstrates how to check the action sheet’s item’s state:
JavaScript, JScript
{
// Select the mobile device
Mobile.SetCurrent("iPhone");
// Obtain the ActionSheet object
var p = Mobile.Device().Process("SampleApp");
var actionSheet = p.Window(0).ActionSheet();
// Check whether the item is enabled
if (actionSheet.wItemEnabled("Item"))
// Touch the item
actionSheet.TouchItem("Item");
}
Python
def Test():
# Select the mobile device
Mobile.SetCurrent("iPhone")
# Obtain the ActionSheet object
p = Mobile.Device().Process("SampleApp")
actionSheet = p.Window(0).ActionSheet()
# Check whether the item is enabled
if actionSheet.wItemEnabled["Item"]:
# Touch the item
actionSheet.TouchItem("Item")
VBScript
' Select the mobile device
Mobile.SetCurrent("iPhone")
' Obtain the ActionSheet object
Set p = Mobile.Device.Process("SampleApp")
Set actionSheet = p.Window(0).ActionSheet
' Check whether the item is enabled
If actionSheet.wItemEnabled("Item") Then
' Touch the item
actionSheet.TouchItem("Item")
End If
End Sub
DelphiScript
var p, actionSheet;
begin
// Select the mobile device
Mobile.SetCurrent('iPhone');
// Obtain the ActionSheet object
p := Mobile.Device.Process('SampleApp');
actionSheet := p.Window(0).ActionSheet();
// Check whether the item is enabled
if actionSheet.wItemEnabled('Item') then
// Touch the item
actionSheet.TouchItem('Item');
end;
C++Script, C#Script
{
// Select the mobile device
Mobile["SetCurrent"]("iPhone");
// Obtain the ActionSheet object
var p = Mobile["Device"]["Process"]("SampleApp");
var actionSheet = p["Window"](0)["ActionSheet"]();
// Check whether the item is enabled
if (actionSheet["wItemEnabled"]("Item"))
// Touch the item
actionSheet["TouchItem"]("Item");
}
Checking State From Keyword Tests
To check the state of the action sheet items from keyword tests, use the On-Screen Action or Call Object Method operation to access the properties described above. See Getting and Setting Object Property Values.
See Also
Working With iOS ActionSheet Controls
Selecting an ActionSheet Control's Item