Skip to content
Sahi Pro Flowcharts is retired. These pages document the last release (v12) and are no longer updated. Go to the current documentation.Flowcharts is retired. Current docs
Get Free Trial
Sahi Pro Flowcharts is retired. These pages document the last release (v12) and are no longer updated. Go to the current documentation.

iOS APIs

This page lists the APIs specific to iOS. These APIs have an _i prefix in camel case, example: _iRotate. These APIs will work only on an iOS device/simulator.

Modes iOS

Simulates two finger touches on an element, each with a single tap.

Parameters

NameTypeDescription
$elementiOS ElementElement to be tapped.
Raw script
_iTwoFingerTap(_image("abc"));

Sahi Pro Classic API _iTwoFingerTap

ITap With Number Of Taps Number Of Touches

Section titled “ITap With Number Of Taps Number Of Touches”

Modes iOS

Simulates number of finger touches on an element, each with a number of taps. NOTE that the first parameter is for taps and the second is for touches.

Parameters

NameTypeDescription
$elementiOS Elementelement to be tapped
$tapsintegerNumber of taps
$touchesintegerNumber of touches.
Raw script
_iTapWithNumberOfTapsNumberOfTouches(_iMap(0), 2, 1); // One touch, with two taps. Same as _doubleClick
_iTapWithNumberOfTapsNumberOfTouches(_iMap(0), 1, 2); // Two touches, each with a single tap. Same as _iTwoFingerTap

Sahi Pro Classic API _iTapWithNumberOfTapsNumberOfTouches

Modes iOS

Simulates a rotation gesture on an element.

Parameters

NameTypeDescription
$elementiOS ElementElement to be rotated
$rotationAnglefloatRotation of the gesture in radians. A positive value indicates a clockwise rotation. A negative value indicates counter clockwise rotation.
$velocityfloatVelocity of the rotation gesture in radians per second. If rotationAngle is negative, then velocity must be negative.
Raw script
_iRotate(_iMap(0), Math.PI/4, 0.5); // Clockwise rotation
_iRotate(_iMap(0), -Math.PI/4, -0.5); // Counter-clockwise rotation

Sahi Pro Classic API _iRotate

IActivate Siri With Voice Recognition Text

Section titled “IActivate Siri With Voice Recognition Text”

Modes iOS

Activates Siri with voice recognition text.
Works only on iOS devices/simulators with iOS version greater than iOS 10.3.

Parameters

NameTypeDescription
$textstringText to be recognized.
Raw script
_iActivateSiriWithVoiceRecognitionText("Please set a reminder for my meeting with John");

Sahi Pro Classic API _iActivateSiriWithVoiceRecognitionText

Modes iOS

Simulates volume up action on an iOS Device.
Works only on an iOS device, and not on an iOS simulator.

Parameters

NameTypeDescription
None
Raw script
_iPressVolumeUp();

Sahi Pro Classic API _iPressVolumeUp

Modes iOS

Simulates volume down action on an iOS Device.
Works only on an iOS device, and not on an iOS simulator.

Parameters

NameTypeDescription
None
Raw script
_iPressVolumeDown();

Sahi Pro Classic API _iPressVolumeDown

Modes iOS

Returns true if the element is selected. Otherwise, returns false.

Parameters

NameTypeDescription
$elementiOS ElementElement whose isSelected attribute is to be checked.

Returns

booleantrue or false based on whether the element is selected or not.
Raw script
var $selected = _iIsSelected(_button("radio-button"));

Sahi Pro Classic API _iIsSelected

Modes iOS

Returns true if the running platform is an iOS device. Returns false for an iOS simulator.

Parameters

NameTypeDescription
None

Returns

booleantrue or false based on whether the running platform is an iOS device.
Raw script
if (_iIsDevice()) { // Volume down can be simulated only for an iOS device.
_iPressVolumeDown();
}

Sahi Pro Classic API _iIsDevice

Modes iOS

Returns state of application.

Parameters

NameTypeDescription
$bundleIdiOS App Bundle IdBundle id of application whose state is required.Element whose isSelected attribute is to be checked.

Returns

booleanState of application as number.
Raw script
var $state = _iGetApplicationState("com.sahipro.ios.test.SahiTestApp");

Sahi Pro Classic API _iGetApplicationState

In iOS, system dialogs cannot be automated with regular APIs. For example, one cannot use _click to click on the Allow button in a system dialog.

Refer to Automating System Dialogs for details on how to automate a system dialog.

Modes iOS

IExpect System Dialog tells Sahi to click the button with the given buttonIdentifier, for a dialog with given message.

Parameters

NameTypeDescription
$messagestringMessage to expect in dialog. This can also be a regular expression
$buttonIdentifierstring|integerSahi Identifier for the button. Can also be just an index.
$persistbooleanoptionalIf true, will accept a single _iExpectSystemDialog statement for all system dialogs coming after the statement. If false, will accept only the next system dialog to work with the _iExpectSystemDialog statement. Default is false.
Raw script
var $dialogLabelExpected = "/Allow.*Maps.*location/";
var $btnTextToClick = "Allow"; // This will click the "Allow" button
// Set the expected dialog label, and indicate the button to click.
_iExpectSystemDialog($dialogLabelExpected, $btnTextToClick);

Sahi Pro Classic API _iExpectSystemDialog

Modes iOS

For iOS to invoke the system dialog handler, the app has to be interacted with. IInteract With App() does just that.

Parameters

NameTypeDescription
None
Raw script
_iInteractWithApp();

Sahi Pro Classic API _iInteractWithApp

Modes iOS

Parameters

NameTypeDescription
$alldialogsbooleanoptionalIf true, returns array of all system dialog messages.

Returns

stringlast system dialog message if $alldialogs is false
array of stringsan array of all dialog messages in the browser if $alldialogs is true
Raw script
// Return array of all system dialog messages.
var $allMessages = _iLastSystemDialog(true);
// Return only last system dialog message.
var $lastMessage= _iLastSystemDialog();

Sahi Pro Classic API _iLastSystemDialog

Modes iOS

Removes the last system dialog message from session so that further occurrence of system dialogs can be checked

Parameters

NameTypeDescription
None
Raw script
_iClearLastSystemDialog();

Sahi Pro Classic API _iClearLastSystemDialog

var $dialogLabelExpected = "/Allow.*Maps.*location/";
var $btnTextToClick = "Allow";
// Set the expected dialog label, and indicate the button to click.
_iExpectSystemDialog($dialogLabelExpected, $btnTextToClick);
// Activate the Maps application
_mActivateApplication("com.apple.Maps", true);
// Wait a little while so that the system dialog comes up.
_wait(3000);
// IMPORTANT: Interact with the app. This is what will trigger the dialog handler.
_iInteractWithApp();
// Sahi would click on the Allow button now.
// Get the last dialog label and assert that it is same as expected.
var $dialogLabelActual = _iLastSystemDialog();
_assertEqual($dialogLabelExpected, $dialogLabelActual);

Modes iOS

By default, Sahi will try to dismiss keyboard automatically after setting value in the textfield. To disable this functionaity set it to false.
Sahi will try to click on the keyboard button provided by ios.keyboard.buttons.autoclick property in SAHI_INSTALL_PATH\config\sahi.properties.

Parameters

NameTypeDescription
$autoDismissbooleantrue or false

Sahi Pro Classic API _iSetAutoDismissKeyboard