How to use perform method of io.appium.java_client.MultiTouchAction class

Best io.appium code snippet using io.appium.java_client.MultiTouchAction.perform

TestHintHomePage.java

Source:TestHintHomePage.java Github

copy

Full Screen

...63 TouchAction action5 = new TouchAction(driver).longPress(new PointOption().withCoordinates(900, 1875));//964 65 MultiTouchAction multiTouch = new MultiTouchAction(driver);66 multiTouch.add(action1);67 multiTouch.perform();68 69 MultiTouchAction multiTouch2 = new MultiTouchAction(driver);70 multiTouch2.add(action2);71 multiTouch2.perform();72 73 MultiTouchAction multiTouch3 = new MultiTouchAction(driver);74 multiTouch3.add(action3);75 multiTouch3.perform();76 77 MultiTouchAction multiTouch4 = new MultiTouchAction(driver);78 multiTouch4.add(action4);79 multiTouch4.perform();80 81 MultiTouchAction multiTouch5 = new MultiTouchAction(driver);82 multiTouch5.add(new TouchAction(driver).longPress(new PointOption().withCoordinates(200, 1550)));83 multiTouch5.perform();84 85 MultiTouchAction multiTouch6 = new MultiTouchAction(driver);86 multiTouch6.add(new TouchAction(driver).longPress(new PointOption().withCoordinates(200, 1550)));87 multiTouch6.perform();88 89 MultiTouchAction multiTouch7 = new MultiTouchAction(driver);90 multiTouch7.add(action5);91 multiTouch7.perform();92 93 MultiTouchAction multiTouch8 = new MultiTouchAction(driver);94 multiTouch8.add(new TouchAction(driver).longPress(new PointOption().withCoordinates(900, 1875)));95 multiTouch8.perform();96 97 MultiTouchAction multiTouch9 = new MultiTouchAction(driver);98 multiTouch9.add(new TouchAction(driver).longPress(new PointOption().withCoordinates(900, 1875)));99 multiTouch9.perform();100 101 MultiTouchAction multiTouch10 = new MultiTouchAction(driver);102 multiTouch10.add(new TouchAction(driver).longPress(new PointOption().withCoordinates(900, 1875)));103 multiTouch10.perform();104 105 //TODO: NOT WORKING NEED TO FIGUER OUT WHY?106 new MultiTouchAction(driver).add(action1).add(action2).add(action3).add(action4).add(action4).add(action4)107 .add(action5).add(action5).add(action5).add(action5).perform();108 109 Thread.sleep(1000);110 111 Boolean b1 = driver.findElement(By.id("com.hintmd.patientapp:id/login_send_button")).isDisplayed();112 if(b1.equals(true)) {113 System.out.println("After enter phone no SEND Button Appear!");114 }115 116 Thread.sleep(2000);117 driver.quit();118 service.stop();119 }120}...

Full Screen

Full Screen

ZoomingandPinching.java

Source:ZoomingandPinching.java Github

copy

Full Screen

...35TouchAction zoomOut = new TouchAction(driver);36zoomOut.press(PointOption.point(center_X,center_Y-10)).moveTo(PointOption.point(center_X,center_Y-200)).release();37TouchAction zoomIn = new TouchAction(driver);38zoomIn.press(PointOption.point(center_X,center_Y+10)).moveTo(PointOption.point(center_X,center_Y+200)).release();39multiTouchAction.add(zoomOut).add(zoomIn).perform();40System.out.println("zoom Done");41TouchAction finger3= new TouchAction(driver);42finger3.press(ElementOption.element(image, center_X, center_Y-20)).moveTo(ElementOption.element(image,center_X,center_Y-10));43TouchAction finger4= new TouchAction(driver);44finger4.press(ElementOption.element(image, center_X, center_Y+20)).moveTo(ElementOption.element(image, center_X, center_Y+10));45MultiTouchAction action2= new MultiTouchAction(driver);46action2.add(finger3).add(finger4).perform();47System.out.println("Pinch Done");48Thread.sleep(10000);49 50 51 52 }53 54 55 public void zoomingandpinch()56 {57 58 /*WebElement Image = driver.findElementById(“com.davemorrissey.labs.subscaleview.sample:id/imageView”);59 Thread.sleep(5000);60 int x=Image.getLocation().getX()+Image.getSize().getWidth()/2;61 int y= Image.getLocation().getY()+Image.getSize().getHeight()/2;62 63 //Zoom out64 TouchAction finger1= new TouchAction(driver);65 finger1.press(Image, x, y-20).moveTo(Image,x,y-50);66 67 TouchAction finger2= new TouchAction(driver);68 finger2.press(Image, x, y+20).moveTo(Image, x, y+50);69 70 71 72 MultiTouchAction action= new MultiTouchAction(driver);73 action.add(finger1).add(finger2).perform();74 System.out.println("Zoom Done");75 Thread.sleep(10000);76 77 78 TouchAction finger3= new TouchAction(driver);79 finger3.press(Image, x, y-20).moveTo(Image, x, y-10);80 81 TouchAction finger4= new TouchAction(driver);82 finger4.press(Image, x, y+20).moveTo(Image, x, y+10);83 MultiTouchAction action2= new MultiTouchAction(driver);84 action2.add(finger3).add(finger4).perform();85 86 System.out.println("Pinch Done");87 Thread.sleep(10000);*/88 }89 90 @Test(priority = 1)91 public void Find_ScreenOrientation_Test() throws Exception {92 93 94 ScreenOrientation orientation;95 orientation = ScreenOrientation.LANDSCAPE;96 driver.execute(DriverCommand.SET_SCREEN_ORIENTATION,97 ImmutableMap.of("orientation",orientation.value().toUpperCase()));98 ...

Full Screen

Full Screen

test3.java

Source:test3.java Github

copy

Full Screen

...36// PointOption point2 = PointOption.point(706, 465);37// PointOption point3 = PointOption.point(178, 1000);38// PointOption point4 = PointOption.point(706, 1000);39// TouchAction touchAction = new TouchAction(driver);40// touchAction.press(point1).moveTo(point2).moveTo(point3).moveTo(point4).release().perform();41 //多点手势操作 图片放大 缩小42 //核心点:一根手指代表一个TouchAction43 //放大效果模拟44 /*driver.findElement(MobileBy.AccessibilityId("题库")).click();45 PointOption pointA = PointOption.point(368, 565);46 PointOption pointB = PointOption.point(561, 1102);47 PointOption pointC = PointOption.point(722, 1307);48 PointOption pointD = PointOption.point(173, 330);49 //通过touchAction1模拟A-->D50 TouchAction touchAction1 = new TouchAction(driver);51 touchAction1.press(pointA).moveTo(pointD).release();52 //通过touchAction1模拟B-->C53 TouchAction touchAction2 = new TouchAction(driver);54 touchAction2.press(pointB).moveTo(pointC).release();55 //同时执行两根手指的操作56 MultiTouchAction multiTouchAction = new MultiTouchAction(driver);57 multiTouchAction.add(touchAction1);58 multiTouchAction.add(touchAction2);59 multiTouchAction.perform();*/60 }61 //封装下拉方法,适应所有的机型62 public void swipdown(AndroidDriver driver,int swipeTime){63 //模拟下拉操作64 //1.确定滑动起始点(426,598),滑动终止点(426,1192),坐标系统65// //1.确定滑动起始点(426,598),滑动终止点(426,1192),坐标系统66// PointOption point1 = PointOption.point(426, 598);67// PointOption point2 = PointOption.point(426, 1192);68 //1.确定滑动起始点(426,598),滑动终止点(426,1192),坐标系统69 //1.确定滑动起始点(屏幕宽1/2,屏幕高度1/4),滑动终止点(屏幕宽1/2,屏幕高度3/4),坐标系统70 int width = driver.manage().window().getSize().getWidth();71 int height = driver.manage().window().getSize().getHeight();72 PointOption point1 = PointOption.point(width/2, height/4);73 PointOption point2 = PointOption.point(width/2, height*3/4);74 //2.通过TouchAction来模拟滑动过程75 TouchAction touchAction = new TouchAction(driver);76 //先按下,再移动,再手指释放77 //waitAction设置滑动的间隔时间78 Duration duration = Duration.ofMillis(swipeTime);79 WaitOptions waitOptions = WaitOptions.waitOptions(duration);80 touchAction.press(point1).waitAction().moveTo(point2).release().perform();81 }82}

Full Screen

Full Screen

BaseAction.java

Source:BaseAction.java Github

copy

Full Screen

...41 // ³¤°´42 public void longPress(WebElement element) {43 LongPressOptions longPressOptions = LongPressOptions.longPressOptions();44 longPressOptions.withElement(ElementOption.element(element));45 action.longPress(longPressOptions).release().perform();46 }47 // ×ø±êµãµÄ»¬¶¯48 public void swip(PointOption fromOption, PointOption toOption) {49 action.press(fromOption).waitAction(WaitOptions.waitOptions(Duration.ofSeconds(1))).moveTo(toOption)50 .waitAction(WaitOptions.waitOptions(Duration.ofSeconds(1))).release().perform();51 }52 // ÔªËؼäµÄ»¬¶¯53 public void swip(WebElement fromEle, WebElement toEle) {54 PointOption fromOption = PointOption.point(fromEle.getLocation().getX(), fromEle.getLocation().getY());55 PointOption toOption = PointOption.point(toEle.getLocation().getX(), toEle.getLocation().getY());56 swip(fromOption, toOption);57 }58 public void DragAndSwip(AndroidElement element) {59 LongPressOptions longPressOptions = LongPressOptions.longPressOptions();60 longPressOptions.withElement(ElementOption.element(element));61 action.longPress(longPressOptions).waitAction(WaitOptions.waitOptions(Duration.ofSeconds(1)))62 .moveTo(PointOption.point(100, element.getLocation().getY()))63 .waitAction(WaitOptions.waitOptions(Duration.ofSeconds(1))).release().perform();64 }65 public void multiTouch(int x1, int y1, int x2, int y2, int x3, int y3) {66 MultiTouchAction multiAction = new MultiTouchAction(driver);67 AndroidTouchAction action1 = new AndroidTouchAction(driver);68 AndroidTouchAction action2 = new AndroidTouchAction(driver);69 AndroidTouchAction action3 = new AndroidTouchAction(driver);70 AndroidTouchAction action4 = new AndroidTouchAction(driver);71 AndroidTouchAction action5 = new AndroidTouchAction(driver);72 action1.longPress(PointOption.point(x1, y1)).waitAction(WaitOptions.waitOptions(Duration.ofSeconds(1)))73 .release();74 action2.longPress(PointOption.point(x2, y2)).waitAction(WaitOptions.waitOptions(Duration.ofSeconds(1)))75 .release();76 action3.longPress(PointOption.point(x3, y3)).waitAction(WaitOptions.waitOptions(Duration.ofSeconds(1)))77 .release();78 multiAction.add(action1).add(action2).add(action3).add(action4).add(action5).perform();79 }80 81 public String getToast() {82 return driver.findElementByXPath("//*[@class='android.widget.Toast']").getText();83 }84}...

Full Screen

Full Screen

Test49.java

Source:Test49.java Github

copy

Full Screen

...65 .waitAction(WaitOptions.waitOptions(Duration.ofSeconds(1)))66 .moveTo(ElementOption.element(s2,size2.width-10,size2.height/2));67 //Perform all actions at a time68 MultiTouchAction ma=new MultiTouchAction(driver);69 ma.add(ta1).add(ta2).perform(); 70 Thread.sleep(10000);71 }72 catch(Exception ex)73 {74 System.out.println(ex.getMessage());75 }76 //Close App77 driver.closeApp();78 //Stop appium server79 Runtime.getRuntime().exec("taskkill /F /IM node.exe");80 Runtime.getRuntime().exec("taskkill /F /IM cmd.exe"); 81 }82}...

Full Screen

Full Screen

MutliTouchActionDemo.java

Source:MutliTouchActionDemo.java Github

copy

Full Screen

...30 touchAction1.tap(TapOptions.tapOptions().withElement(ElementOption.element(ele)));31 TouchAction touchAction2=new TouchAction(driver);32 touchAction2.tap(PointOption.point(488, 803));33 MultiTouchAction multiTouchAction=new MultiTouchAction(driver);34 multiTouchAction.add(touchAction1).add(touchAction2).perform();35 Thread.sleep(5000);36 }37}

Full Screen

Full Screen

NativeApp5ZoomTest2.java

Source:NativeApp5ZoomTest2.java Github

copy

Full Screen

...41 .moveTo(PointOption.point(500, 1700));4243 MultiTouchAction multi=new MultiTouchAction(driver);44 45// multi.add(touch1).add(touch2).perform();46 47 for(int i=1;i<=3;i++)48 {49 multi.add(touch1).add(touch2).perform();50 }51 52 }5354} ...

Full Screen

Full Screen

MultiTouchActionTest.java

Source:MultiTouchActionTest.java Github

copy

Full Screen

...28// tap at a location -->TouchAction--> tap29 30 TouchAction t= new TouchAction(driver);31 32 t.tap(PointOption.point(309,879)).perform(); 33 34 35 //1st finger action simulation36 37TouchAction t1= new TouchAction(driver).press(PointOption.point(580,790))38 .waitAction(WaitOptions.waitOptions(Duration.ofSeconds(3)))39 .moveTo(PointOption.point(845,350)).release();40 41 42 //thumb action simulation43 44TouchAction t2= new TouchAction(driver).press(PointOption.point(410,1054))45 .waitAction(WaitOptions.waitOptions(Duration.ofSeconds(3)))46 .moveTo(PointOption.point(180,1420)).release();47 48 49 MultiTouchAction mta= new MultiTouchAction(driver);50 51 mta.add(t1).add(t2).perform();52 53 54 55 56 57 58 59 60 61 62 63 64 65 ...

Full Screen

Full Screen

perform

Using AI Code Generation

copy

Full Screen

1import io.appium.java_client.MultiTouchAction;2import io.appium.java_client.TouchAction;3import io.appium.java_client.android.AndroidDriver;4import io.appium.java_client.android.AndroidElement;5import java.net.MalformedURLException;6import java.net.URL;7import org.openqa.selenium.By;8import org.openqa.selenium.remote.DesiredCapabilities;9public class MultiTouchActions {10public static void main(String[] args) throws MalformedURLException, InterruptedException {11DesiredCapabilities cap = new DesiredCapabilities();12cap.setCapability("deviceName", "Android Emulator");13cap.setCapability("platformName", "Android");14cap.setCapability("platformVersion", "5.0.2");15cap.setCapability("appPackage", "com.android.calculator2");16cap.setCapability("appActivity", "com.android.calculator2.Calculator");

Full Screen

Full Screen

perform

Using AI Code Generation

copy

Full Screen

1MultiTouchAction multiTouch = new MultiTouchAction(driver);2multiTouch.perform();3TouchAction touchAction = new TouchAction(driver);4touchAction.perform();5TouchAction touchAction = new TouchAction(driver);6touchAction.perform();7TouchAction touchAction = new TouchAction(driver);8touchAction.perform();9TouchAction touchAction = new TouchAction(driver);10touchAction.perform();11TouchAction touchAction = new TouchAction(driver);12touchAction.perform();13TouchAction touchAction = new TouchAction(driver);14touchAction.perform();15TouchAction touchAction = new TouchAction(driver);16touchAction.perform();17TouchAction touchAction = new TouchAction(driver);18touchAction.perform();19TouchAction touchAction = new TouchAction(driver);20touchAction.perform();21TouchAction touchAction = new TouchAction(driver);22touchAction.perform();23TouchAction touchAction = new TouchAction(driver);24touchAction.perform();25TouchAction touchAction = new TouchAction(driver);26touchAction.perform();27TouchAction touchAction = new TouchAction(driver);28touchAction.perform();

Full Screen

Full Screen

perform

Using AI Code Generation

copy

Full Screen

1import io.appium.java_client.MultiTouchAction;2import io.appium.java_client.TouchAction;3import io.appium.java_client.AppiumDriver;4import io.appium.java_client.android.AndroidDriver;5import org.openqa.selenium.WebElement;6import org.openqa.selenium.By;7import java.net.URL;8import org.openqa.selenium.remote.DesiredCapabilities;9import java.lang.InterruptedException;10public class MultiTouchActionTest {11 public static void main(String[] args) throws Exception {12 DesiredCapabilities capabilities = new DesiredCapabilities();13 capabilities.setCapability("deviceName", "Android Emulator");14 capabilities.setCapability("browserName", "Android");15 capabilities.setCapability("platformVersion", "4.4.2");16 capabilities.setCapability("platformName", "Android");17 capabilities.setCapability("appPackage", "com.android.calculator2");18 capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");

Full Screen

Full Screen

perform

Using AI Code Generation

copy

Full Screen

1package appium.java;2import io.appium.java_client.MultiTouchAction;3import io.appium.java_client.TouchAction;4import io.appium.java_client.android.AndroidDriver;5import io.appium.java_client.android.AndroidElement;6import io.appium.java_client.remote.MobileCapabilityType;7import io.appium.java_client.remote.MobilePlatform;8import java.io.File;9import java.net.MalformedURLException;10import java.net.URL;11import java.util.concurrent.TimeUnit;12import org.openqa.selenium.remote.DesiredCapabilities;13public class PerformPinchZoom {14 public static void main(String[] args) throws MalformedURLException, InterruptedException {15 File appDir = new File("src");16 File app = new File(appDir, "ApiDemos-debug.apk");17 DesiredCapabilities capabilities = new DesiredCapabilities();18 capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);19 capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");20 capabilities.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());

Full Screen

Full Screen

perform

Using AI Code Generation

copy

Full Screen

1package appium;2import java.net.MalformedURLException;3import java.net.URL;4import java.util.concurrent.TimeUnit;5import org.openqa.selenium.By;6import org.openqa.selenium.WebElement;7import org.openqa.selenium.remote.DesiredCapabilities;8import org.openqa.selenium.support.ui.ExpectedConditions;9import org.openqa.selenium.support.ui.WebDriverWait;10import io.appium.java_client.AppiumDriver;11import io.appium.java_client.MultiTouchAction;12import io.appium.java_client.TouchAction;13import io.appium.java_client.android.AndroidDriver;14public class MultiTouchActionDemo {15 public static void main(String[] args) throws MalformedURLException, InterruptedException {16 DesiredCapabilities capabilities = new DesiredCapabilities();17 capabilities.setCapability("deviceName", "ZX1G224JL6");18 capabilities.setCapability("platformName", "Android");19 capabilities.setCapability("platformVersion", "5.1.1");20 capabilities.setCapability("appPackage", "com.android.calculator2");21 capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");

Full Screen

Full Screen

perform

Using AI Code Generation

copy

Full Screen

1import io.appium.java_client.AppiumDriver;2import io.appium.java_client.MultiTouchAction;3import io.appium.java_client.TouchAction;4import io.appium.java_client.android.AndroidDriver;5import io.appium.java_client.android.AndroidKeyCode;6import io.appium.java_client.ios.IOSDriver;7import io.appium.java_client.ios.IOSElement;8import io.appium.java_client.remote.MobileCapabilityType;9import io.appium.java_client.touch.offset.PointOption;10import java.net.MalformedURLException;11import java.net.URL;12import java.time.Duration;13import java.util.concurrent.TimeUnit;14import org.openqa.selenium.By;15import org.openqa.selenium.Dimension;16import org.openqa.selenium.Point;17import org.openqa.selenium.WebElement;18import org.openqa.selenium.remote.DesiredCapabilities;19public class PinchZoomTest {20 public static void main(String[] args) throws MalformedURLException, InterruptedException {21 DesiredCapabilities caps = new DesiredCapabilities();22 caps.setCapability("deviceName", "Pixel 3a API 29");23 caps.setCapability("udid", "emulator-5554");24 caps.setCapability("platformName", "Android");25 caps.setCapability("platformVersion", "10.0");26 caps.setCapability("automationName", "UiAutomator2");27 caps.setCapability("appPackage", "com.oneplus.gallery");28 caps.setCapability("appActivity", "com.oneplus.gallery.activities.GalleryActivity");29 caps.setCapability("noReset", true);

Full Screen

Full Screen

perform

Using AI Code Generation

copy

Full Screen

1import io.appium.java_client.MultiTouchAction;2import io.appium.java_client.TouchAction;3import io.appium.java_client.android.AndroidDriver;4import java.net.URL;5import org.openqa.selenium.remote.DesiredCapabilities;6import org.testng.annotations.Test;7public class MultiTouchActionExample {8public void testMultiTouchAction() throws Exception {9DesiredCapabilities capabilities=DesiredCapabilities.android();10capabilities.setCapability("browserName", "Chrome");11capabilities.setCapability("platformName", "Android");12capabilities.setCapability("platformVersion", "4.4.2");13capabilities.setCapability("deviceName", "Android Emulator");

Full Screen

Full Screen

perform

Using AI Code Generation

copy

Full Screen

1import io.appium.java_client.MultiTouchAction;2import io.appium.java_client.TouchAction;3import io.appium.java_client.android.AndroidDriver;4import io.appium.java_client.android.AndroidElement;5import io.appium.java_client.remote.MobileCapabilityType;6import java.net.MalformedURLException;7import java.net.URL;8import java.util.concurrent.TimeUnit;9import org.openqa.selenium.By;10import org.openqa.selenium.remote.DesiredCapabilities;11import org.testng.annotations.AfterTest;12import org.testng.annotations.BeforeTest;13import org.testng.annotations.Test;14import io.appium.java_client.MultiTouchAction;15import io.appium.java_client.TouchAction;16import io.appium.java_client.android.AndroidDriver;17import io.appium.java_client.android.AndroidElement;18import io.appium.java_client.remote.MobileCapabilityType;19import java.net.MalformedURLException;20import java.net.URL;21import java.util.concurrent.TimeUnit;22import org.openqa.selenium.By;23import org.openqa.selenium.remote.DesiredCapabilities;24import org.testng.annotations.AfterTest;25import org.testng.annotations.BeforeTest;26import org.testng.annotations.Test;27public class Appium {28AndroidDriver<AndroidElement> driver;29public void setup() throws MalformedURLException {30DesiredCapabilities cap = new DesiredCapabilities();31cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Android");32cap.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");33cap.setCapability(MobileCapabilityType.BROWSER_NAME, "Chrome");

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run io.appium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in MultiTouchAction

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful