Skip to content

How do I zoom in a mobile app?

In this example, we will take a look at how to perform the zoom function by using twoFingerDrag command on PDF in the HICC Prod application.

The functionality of the command can be achieved by providing coordinates of both fingers (starting and ending points) in ‘target field’.

It would look like in the following format: x1,y1,x2,y2,x3,y3,x4,y4.

  • x1,y1 being the start point of finger 1 and x2,y2 is the destination point of finger 1.
  • x3,y3 being the start point of finger 2 and x4,y4 being the destination point of finger 2.

Solution:

# Command Target Value
Simulates user using two fingers to zoom in on HICC PDF page
1 twoFingerDrag 250,445,250,170,250,446,250,700

Tips, Tricks, Gotchas & Best Practices:

  • You can get the coordinates from Appium Inspector.
  • Since the screen size varies between devices, to improve reliability we could use elements as our reference points if they are present and get coordinates by using the storeElementLocation command and call those coordinates into the target field.
  • Alternatively, we can also use doubleTap command with locator to zoom in which would work across different devices as the locators do not vary unlike coordinates.
  • Alternatively, we can also use doubleTap command with locator to zoom in which would work across different devices as the locators do not vary unlike coordinates.
  • You can verify whether the screen has zoomed in by using capturePageScreenShot command and view the screenshot.

Feedback and Knowledge Base