Pefrorm MultiTouch Action Using Appium In Android Application Automation

MultiTouch Action In android mobile software app Is 1 of the mutual action. Earlier nosotros larn usage of TouchAction course of report In appium android software automation essay to perform DRAG AND DROP as well as SWIPE ELEMENT. You also needs to automate multi affect activity In your android mobile software app. Here I accept demonstrated uncomplicated instance on how to perform multi affect activity In your android mobile softwareapp.

Install MultiTouch Tester App In Android Mobile
We volition use MultiTouch Tester software App In this android appium multi affect activity automation essay example. So you lot postulate to download as well as Install MultiTouch Tester android software App In your mobile device. You tin download as well as Install MultiTouch Tester App from THIS PAGE.

Aim To Achieve In This Test
We wants to perform multi affect at v dissimilar points at the same fourth dimension on MultiTouch Tester App's covert equally shown In bellow Image.


This Is what nosotros wants to accomplish from this appium android essay example.

Get X And Y Coordinates Of All Touch Points
In inwards a higher house Image you lot tin come across that at that spot are v points where nosotros wants to perform MultiTouch Action In appium android automation test. You tin choke X Y Coordinates of all v affect points manually using uiautomatorviewer too equally described In THIS POST

In our appium test, We volition calculate X as well as Y Coordinates of all v touching points pragmatically by calculating screen's width  and as well as thus volition choke dissimilar 10 as well as y points using size.width and size.height methods.

Create And Run Android Appium MultiTouch Action Test
Create new MultiTouch.java file nether your projection as well as re-create glue bellow given essay script Inside It.

package Android;  import io.appium.java_client.MobileDriver; import io.appium.java_client.MultiTouchAction; import io.appium.java_client.TouchAction; import io.appium.java_client.android.AndroidDriver; import java.net.URL; import java.util.concurrent.TimeUnit; import org.openqa.selenium.Dimension; import org.openqa.selenium.remote.DesiredCapabilities; import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test;  world course of report MultiTouch {  AndroidDriver driver;  Dimension size;   @BeforeTest  world void setUp() throws Exception {   DesiredCapabilities capabilities = novel DesiredCapabilities();   capabilities.setCapability("deviceName", "ZX1B32FFXF");   capabilities.setCapability("browserName", "Android");   capabilities.setCapability("platformVersion", "4.4.2");   capabilities.setCapability("platformName", "Android");   capabilities.setCapability("appPackage","com.the511plus.MultiTouchTester");   capabilities.setCapability("appActivity","com.the511plus.MultiTouchTester.MultiTouchTester");   driver = novel AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);   driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);  }   @Test  world void mTouchAction() throws InterruptedException {      size = driver.manage().window().getSize();   //Get X Y Coordinates for affect activity 1(Top left side).   int x1 = (int) (size.width * 0.20);   int y1 = (int) (size.height * 0.20);      //Get X Y Coordinates for affect activity 2(Top correct side).   int x2 = (int) (size.width * 0.80);   int y2 = (int) (size.height * 0.20);      //Get X Y Coordinates for affect activity 3(Bottom left side).   int x3 = (int) (size.width * 0.20);   int y3 = (int) (size.height * 0.80);      //Get X Y Coordinates for affect activity 4(Bottom correct side).   int x4 = (int) (size.width * 0.80);   int y4 = (int) (size.height * 0.80);      //Get X Y Coordinates for affect activity 5(middle of the screen).   int x5 = size.width / 2;   int y5 = size.height / 2;      // Create object of MultiTouchAction class.   MultiTouchAction maction = novel MultiTouchAction((MobileDriver) driver);    // Set affect action1 on given X Y Coordinates of screen.   TouchAction action1 = novel TouchAction((MobileDriver) driver).longPress(x1, y1).waitAction(1500);   // Set affect action2 on given X Y Coordinates of screen.   TouchAction action2 = novel TouchAction((MobileDriver) driver).longPress(x2, y2).waitAction(1500);   // Set affect action3 on given X Y Coordinates of screen.   TouchAction action3 = novel TouchAction((MobileDriver) driver).longPress(x3, y3).waitAction(1500);   // Set affect action4 on given X Y Coordinates of screen.   TouchAction action4 = novel TouchAction((MobileDriver) driver).longPress(x4, y4).waitAction(1500);   // Set affect action5 on given X Y Coordinates of screen.   TouchAction action5 = novel TouchAction((MobileDriver) driver).longPress(x5, y5).waitAction(1500);    // Generate multi affect activity chain using dissimilar actions as well as perform It.   maction.add(action1).add(action2).add(action3).add(action4).add(action5).perform();  }   @AfterTest  world void End() {   driver.quit();  } }

MultiTouch Action Script Description
In inwards a higher house essay you lot tin see,
  • First of all nosotros accept collected X as well as Y coordinates(x1,y1, x2,y2, ..ect) for dissimilar affect indicate positions.
  • MultiTouchAction Is a course of report which provides us a facility to generate multi affect activity chain using affect activity chain.
  • We accept created affect activity chain for all v affect points using TouchAction class.
  • And as well as thus added all v affect actions In MultiTouchAction chain using .add(TouchAction action) method.
  • perform() activity volition perform steps given In MultiTouchAction chain.
Now you lot tin piece of occupation inwards a higher house essay script In your android mobile device using appium as well as testng. It volition launch MultiTouch Tester App In your android mobile device as well as and thus perform multitouch action.


More interesting articles here :Generation Enggelmundus Internet Marketing Tool here :Zeageat IM http://www.software-testing-tutorials-automation.com/
Post a Comment (0)
Previous Post Next Post