Android APIs
This page lists the APIs specific to Android. These APIs have an _a prefix in camel case, example: _aPressBack. These APIs will work only on an Android device/emulator.
Action APIs
Section titled “Action APIs”AWake Up
Section titled “AWake Up”Modes Android
AWake Up simulates pressing the power button if the screen is OFF else it does nothing if the screen is already ON.
Parameters
| Name | Type | Description |
|---|---|---|
None |
Sahi Pro Classic API _aWakeUp
APress Back
Section titled “APress Back”Modes Android
APress Back Performs a Back action.
Parameters
| Name | Type | Description |
|---|---|---|
None |
Sahi Pro Classic API _aPressBack
APress Recent Apps
Section titled “APress Recent Apps”Modes Android
APress Recent Apps Brings up the Recent Apps screen.
Parameters
| Name | Type | Description |
|---|---|---|
None |
Sahi Pro Classic API _aPressRecentApps
APress Search
Section titled “APress Search”Modes Android
APress Search Brings up the Search box.
Parameters
| Name | Type | Description |
|---|---|---|
None |
Sahi Pro Classic API _aPressSearch
APress Menu
Section titled “APress Menu”Modes Android
APress Menu Simulates a press on the MENU button.
Parameters
| Name | Type | Description |
|---|---|---|
None |
Sahi Pro Classic API _aPressMenu
APress Enter
Section titled “APress Enter”Modes Android
APress Enter Simulates a press on the ENTER key.
Parameters
| Name | Type | Description |
|---|---|---|
None |
Sahi Pro Classic API _aPressEnter
APress Delete
Section titled “APress Delete”Modes Android
APress Delete Simulates a press on the DELETE key.
Parameters
| Name | Type | Description |
|---|---|---|
None |
Sahi Pro Classic API _aPressDelete
Fetch APIs
Section titled “Fetch APIs”AIs Screen On
Section titled “AIs Screen On”Modes Android
Returns true or false based on screen is ON or OFF.
Parameters
| Name | Type | Description |
|---|---|---|
None |
Returns
boolean | true or false based based on screen is ON or OFF. |
Raw script
var $screenOn = _aIsScreenOn();Sahi Pro Classic API _aIsScreenOn
Implicit scroll APIs for element identification
Section titled “Implicit scroll APIs for element identification”In Android, only visible elements can be interacted with. Thus if a scroll view has elements that do not lie on the screen, these elements cannot be interacted with, unless they are scrolled into view. In a scroll view that can contain different numbers of elements at different times, the user will first have to determine how much to scroll. To save the user this trouble, Sahi provides APIs that automatically perform the scrolling to identify the element.
AEnable Vertical Scroll
Section titled “AEnable Vertical Scroll”Modes Android
Enables automatic vertical scrolling and disables horizontal scrolling for element identification. This affects all subsequent steps in the script. To turn it off, call _aDisableScroll().
Once AEnable Vertical Scroll has been called, an element is identified as follows.
- When an element is identified, if an _in clause is specified, it will be identified in that container. Else it will be identified in the topmost container.
- If the element is visible on the page, it will be identified.
- Else, if the container is scrollable, it will be scrolled vertically from the beginning till the element is identified. If the end has been reached, it means that the element has not been found.
- Else, if the container is not scrollable but contains a scrollable child container, the child container will be scrolled vertically from the beginning till the element is identified. If the end has been reached, it means that the element has not been found.
Parameters
| Name | Type | Description |
|---|---|---|
$element | Android Elementoptional | Scrollable element in which subsequent elements will be searched. If not specified, top most scrollable element will be considered. |
$maxScrollCount | integeroptional | Specify maximum scroll count to attempt scrolling to identify an element. If not specified, it will perform the scrolling till the end. |
Sahi Pro Classic API _aEnableVerticalScroll
AEnable Horizontal Scroll
Section titled “AEnable Horizontal Scroll”Modes Android
Enables automatic horizontal scrolling and disables vertical scrolling for element identification. This affects all subsequent steps in the script. To turn it off, call _aDisableScroll().
Once AEnable Horizontal Scroll has been called, an element is identified as follows.
- When an element is identified, if an _in clause is specified, it will be identified in that container. Else it will be identified in the topmost container.
- If the element is visible on the page, it will be identified.
- Else, if the container is scrollable, it will be scrolled horizontally from the beginning till the element is identified. If the end has been reached, it means that the element has not been found.
- Else, if the container is not scrollable but contains a scrollable child container, the child container will be scrolled horizontally from the beginning till the element is identified. If the end has been reached, it means that the element has not been found.
Parameters
| Name | Type | Description |
|---|---|---|
$element | Android Elementoptional | Scrollable element in which subsequent elements will be searched. If not specified, top most scrollable element will be considered. |
$maxScrollCount | integeroptional | Specify maximum scroll count to attempt scrolling to identify an element. If not specified, it will perform the scrolling till the end. |
Sahi Pro Classic API _aEnableHorizontalScroll
ADisable Scroll
Section titled “ADisable Scroll”Modes Android
Disables automatic horizontal and vertical scrolling for element identification. This affects all subsequent steps in the script.
Once ADisable Scroll has been called, an element is identified as follows.
- When an element is identified, if an _in clause is specified, it will be identified in that container. Else it will be identified in the topmost container.
- If the element is visible on the page, it will be identified. Else it means that the element has not been found.
Parameters
| Name | Type | Description |
|---|---|---|
None |
Sahi Pro Classic API _aDisableScroll
AIs Vertical Scroll Enabled
Section titled “AIs Vertical Scroll Enabled”Modes Android
Returns true if automatic vertical scrolling has been enabled by calling _aEnableVerticalScroll().
Parameters
| Name | Type | Description |
|---|---|---|
None |
Returns
boolean | true or false based on vertical scrolling is enabled or not. |
Raw script
var $enabled = _aIsVerticalScrollEnabled();Sahi Pro Classic API _aIsVerticalScrollEnabled
AIs Horizontal Scroll Enabled
Section titled “AIs Horizontal Scroll Enabled”Modes Android
Returns true if automatic horizontal scrolling has been enabled by calling _aEnableHorizontalScroll().
Parameters
| Name | Type | Description |
|---|---|---|
None |
Returns
boolean | true or false based on horizontal scrolling is enabled or not. |
Raw script
var $enabled = _aIsHorizontalScrollEnabled();Sahi Pro Classic API _aIsHorizontalScrollEnabled
AIs Scroll Enabled
Section titled “AIs Scroll Enabled”Modes Android
Returns true if automatic horizontal or vertical scrolling has been enabled by calling _aEnableVerticalScroll() or _aEnableHorizontalScroll().
Parameters
| Name | Type | Description |
|---|---|---|
None |
Returns
boolean | true or false based on vertical/horizontal scrolling is enabled or not. |
Raw script
var $enabled = _aIsScrollEnabled();Sahi Pro Classic API _aIsScrollEnabled
Explicit scroll APIs
Section titled “Explicit scroll APIs”AScroll Left Most
Section titled “AScroll Left Most”Modes Android
Scrolls the element’s contents to the leftmost position, i.e. it scrolls horizontally to the beginning. Returns true or false.
Parameters
| Name | Type | Description |
|---|---|---|
$element | Android Element | element to be scrolled |
$maxSwipes | integeroptional | maximum swipes to attempt to scroll to the leftmost position. If not specified, the default max swipes as supported by the device will be used. |
Returns
boolean | true or false based based whether the element can still scroll. |
Raw script
_aScrollLeftMost(_mScrollView("Test"));_aScrollLeftMost(_mScrollView("Test"), 5); //this will perform 5 swipes onlySahi Pro Classic API _aScrollLeftMost
AScroll Right Most
Section titled “AScroll Right Most”Modes Android
Scrolls the element’s contents to the rightmost position, i.e. it scrolls horizontally to the end. Returns true or false.
Parameters
| Name | Type | Description |
|---|---|---|
$element | Android Element | element to be scrolled |
$maxSwipes | integeroptional | maximum swipes to attempt to scroll to the rightmost position. If not specified, the default max swipes as supported by the device will be used. |
Returns
boolean | true or false based based whether the element can still scroll. |
Raw script
_aScrollRightMost(_mScrollView("Test"));_aScrollRightMost(_mScrollView("Test"), 5); //this will perform 5 swipes onlySahi Pro Classic API _aScrollRightMost
AScroll Top Most
Section titled “AScroll Top Most”Modes Android
Scrolls the element’s contents to the topmost position, i.e. it scrolls vertically to the beginning. Returns true or false.
Parameters
| Name | Type | Description |
|---|---|---|
$element | Android Element | element to be scrolled |
$maxSwipes | integeroptional | maximum swipes to attempt to scroll to the topmost position. If not specified, the default max swipes as supported by the device will be used. |
Returns
boolean | true or false based based whether the element can still scroll. |
Raw script
_aScrollTopMost(_mScrollView("Test"));_aScrollTopMost(_mScrollView("Test"), 5); //this will perform 5 swipes onlySahi Pro Classic API _aScrollTopMost
AScroll Bottom Most
Section titled “AScroll Bottom Most”Modes Android
Scrolls the element’s contents to the bottommost position, i.e. it scrolls vertically to the end. Returns true or false.
Parameters
| Name | Type | Description |
|---|---|---|
$element | Android Element | element to be scrolled |
$maxSwipes | integeroptional | maximum swipes to attempt to scroll to the bottommost position. If not specified, the default max swipes as supported by the device will be used. |
Returns
boolean | true or false based based whether the element can still scroll. |
Raw script
_aScrollBottomMost(_mScrollView("Test"));_aScrollBottomMost(_mScrollView("Test"), 5); //this will perform 5 swipes onlySahi Pro Classic API _aScrollBottomMost
AScroll Left
Section titled “AScroll Left”Modes Android
Scrolls the element’s contents one page to the left. Returns false if content cannot be scrolled further, true otherwise.
Parameters
| Name | Type | Description |
|---|---|---|
$element | Android Element | element to be scrolled |
$percent | floatoptional | percent to scroll the element, If not specified, a value of 1.0 will be used. |
$speed | integeroptional | speed to perform scroll, If not specified, default value will be used specific to device. |
Returns
boolean | true or false based based whether the element can still scroll. |
Raw script
_aScrollLeft(_mScrollView("Test"));_aScrollLeft(_mScrollView("Test"), 0.5, 1000);Sahi Pro Classic API _aScrollLeft
AScroll Right
Section titled “AScroll Right”Modes Android
Scrolls the element’s contents one page to the right. Returns false if content cannot be scrolled further, true otherwise.
Parameters
| Name | Type | Description |
|---|---|---|
$element | Android Element | element to be scrolled |
$percent | floatoptional | percent to scroll the element, If not specified, a value of 1.0 will be used. |
$speed | integeroptional | speed to perform scroll, If not specified, default value will be used specific to device. |
Returns
boolean | true or false based based whether the element can still scroll. |
Raw script
_aScrollRight(_mScrollView("Test"));_aScrollRight(_mScrollView("Test"), 0.5, 1000);Sahi Pro Classic API _aScrollRight
AScroll Up
Section titled “AScroll Up”Modes Android
Scrolls the element’s contents one page up. Returns false if content cannot be scrolled further, true otherwise.
Parameters
| Name | Type | Description |
|---|---|---|
$element | Android Element | element to be scrolled |
$percent | floatoptional | percent to scroll the element, If not specified, a value of 1.0 will be used. |
$speed | integeroptional | speed to perform scroll, If not specified, default value will be used specific to device. |
Returns
boolean | true or false based based whether the element can still scroll. |
Raw script
_aScrollUp(_mScrollView("Test"));_aScrollUp(_mScrollView("Test"), 0.5, 1000);Sahi Pro Classic API _aScrollUp
AScroll Down
Section titled “AScroll Down”Modes Android
Scrolls the element’s contents one page down. Returns false if content cannot be scrolled further, true otherwise.
Parameters
| Name | Type | Description |
|---|---|---|
$element | Android Element | element to be scrolled |
$percent | floatoptional | percent to scroll the element, If not specified, a value of 1.0 will be used. |
$speed | integeroptional | speed to perform scroll, If not specified, default value will be used specific to device. |
Returns
boolean | true or false based based whether the element can still scroll. |
Raw script
_aScrollDown(_mScrollView("Test"));_aScrollDown(_mScrollView("Test"), 0.5, 1000);Sahi Pro Classic API _aScrollDown
Android WebView APIs
Section titled “Android WebView APIs”Other APIs
Section titled “Other APIs”ASet Swipe Deadzone Percentage
Section titled “ASet Swipe Deadzone Percentage”Modes Android
After leaving the dead zone area then it starts swiping.
Parameters
| Name | Type | Description |
|---|---|---|
$percent | float | percent to set the deadzone for Swipe gesture. |
Raw script
_aSetSwipeDeadzonePercentage(0.1);Sahi Pro Classic API _aSetSwipeDeadzonePercentage

