Scroll iOS application using Appium


When creating test scripts for iOS native app we need to perform scroll to perform any other action on particular element 

Here we will get to know different kind of scroll options available for iOS using appium

Here scrolling is using the Appium mobile:scroll command. This command will perform using  executeScript() method.

1. Scrolling to the particular UI Element. This requires some identifier of the element that we want to make visible. Use any of the following options available as per the identifier.

  • element: The ID of parent UI element – element must a scrollable element.
  • predicateString: A predicate string that describes, using attribute values(name, label or value) the target UI element.


@iOSXCUITFindBy(className   "XCUIElementTypeTable")
IOSElement parent;
  //identifying the parent Table
 String parentID = parent.getId();
 HashMap<String, String> scrollObject = new HashMap<String, String>();
 scrollObject.put("element", parentID);
 
// Use the predicate that provides the value of the label attribute

 scrollObject.put("predicateString""label == 'elementLabel'");
// scroll to the target element
 driver.executeScript("mobile:scroll", scrollObject);  

2. Scrolling in units of the visible parts of the elements on the device screen. 
This option requires 2 parameters:
  • element”: The id of the element that you want to scroll – “element” must be scrollable.
  • direction”: “up”, “down”, “left, “right”.


@iOSXCUITFindBy(className   "XCUIElementTypeTable")
IOSElement parent;

String elementID = element.getId();
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("element", elementID); // Only for ‘scroll in element’
scrollObject.put("direction""down");
driver.executeScript("mobile:scroll", scrollObject);






No comments:

Post a Comment

Scroll iOS application using Appium

When creating test scripts for iOS native app we need to perform scroll to perform any other action on particular element  Here we will get ...