Silk Mobile

Table of Contents (Homepage)

ElementSwipeWhileNotFound

(String Zone, String SearchElement, String Direction, int Offset, int SwipeTime, String ElementFindZone, String ElementToFind, int ElementToFindIndex, int Delay, int Rounds, Boolean Click)

images/images/os-icons/os_ios_150x150.png

images/images/os-icons/os_android_150x150.png

images/images/os-icons/os_windows_150x150.png

images/images/os-icons/os_blackberry_150x150.png

Description

Swipe inside a component to search for an element or text.

Parameters

  • Zone - Zone of the container element

  • SearchElement - The container element identifier

  • Direction - Direction to swipe

  • Offset - Swipe offset

  • Swipe Time – Time for the swipe action

  • Element to find Zone - Zone of the sought element

  • Element to find - The sought element identifier

  • Element to Find Index – The sought element’s index (i.e., the number of times the element appears after the first appearance minus two). Index=0 refers to the first appearance of the element; Index=1 refers to the second appearance of the element, etc.

  • Delay - Time to wait before sending a command (in milliseconds)

  • Rounds - Maximum swipe rounds

  • Click - Click the found element if TRUE

Usage

Scenario: In this example, we will use the ElementSwipeWhileNotFound command to scroll down in the IMDB application menu, and select the "History" option.

Note: The list doesn’t cover the entire screen. So using SwipeWhileNotFound command may not work on some devices.

images/download/attachments/2689171/1.jpg

Parameters:

  • Component Zone: Will be set to NATIVE

  • Component Element: will be set to id=nav_drawer (This will identify the menu object itself, where the swipe action is going to be performed).

  • Direction: Down

  • Offset: 0

  • Swipe Time: 2000

  • Element Find Zone: NATIVE

  • Element To Find: will be set to text=History (The command will swipe the menu container until this object is found).

  • Element To Find Index: 0

  • Delay: 1000

  • Rounds: 5

  • Click: true (will click the "History" object once it is found).

Result:

List will be scrolled to the bottom until Label History is found.

images/download/attachments/2689171/2.jpg

Once found it will be clicked

images/download/attachments/2689171/3.jpg

Code Examples

Java Example
if(client.elementSwipeWhileNotFound("NATIVE", "id=nav_drawer", "Down", 0, 2000, "NATIVE", "text=History", 0, 1000, 5, true)){
// If statement
}
C# Example
if(client.ElementSwipeWhileNotFound("NATIVE", "id=nav_drawer", "Down", 0, 2000, "NATIVE", "text=History", 0, 1000, 5, true))
{
// If statement
}
VBScript Example
If StrComp (client.ElementSwipeWhileNotFound ( "NATIVE", "id=nav_drawer", "Down", 0, 2000, "NATIVE", "text=History", 0, 1000, 5, true ), "True") = 0 Then
Report
'If statement
Else
Report
End If
Python Example
if(self.client.elementSwipeWhileNotFound("NATIVE", "id=nav_drawer", "Down", 0, 2000, "NATIVE", "text=History", 0, 1000, 5, True)):
# If statement
pass
Perl Example
if($client->elementSwipeWhileNotFound("NATIVE", "id=nav_drawer", "Down", 0, 2000, "NATIVE", "text=History", 0, 1000, 5, 1)){
# If statement
}