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

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

WebDriverWrapper.java

Source:WebDriverWrapper.java Github

copy

Full Screen

...193 public List<WebElement> findElementsById(String id) {194 return ((FindsById) super.getWrappedDriver()).findElementsById(id);195 }196 @Override197 public TouchAction performTouchAction(TouchAction touchAction) {198 return ((PerformsTouchActions) super.getWrappedDriver()).performTouchAction(touchAction);199 }200 @Override201 public void performMultiTouchAction(MultiTouchAction multiAction) {202 ((PerformsTouchActions) super.getWrappedDriver()).performMultiTouchAction(multiAction);203 }204 @Override205 public void launchApp() {206 ((InteractsWithApps) super.getWrappedDriver()).launchApp();207 }208 @Override209 public void installApp(String appPath) {210 ((InteractsWithApps) super.getWrappedDriver()).installApp(appPath);211 }212 @Override213 public boolean isAppInstalled(String bundleId) {214 return ((InteractsWithApps) super.getWrappedDriver()).isAppInstalled(bundleId);215 }216 @Override217 public void resetApp() {218 ((InteractsWithApps) super.getWrappedDriver()).resetApp();219 }220 @Override221 public void runAppInBackground(int seconds) {222 ((InteractsWithApps) super.getWrappedDriver()).runAppInBackground(seconds);223 }224 @Override225 public void removeApp(String bundleId) {226 ((InteractsWithApps) super.getWrappedDriver()).removeApp(bundleId);227 }228 @Override229 public void closeApp() {230 ((InteractsWithApps) super.getWrappedDriver()).closeApp();231 }232 @Override233 public byte[] pullFile(String remotePath) {234 return ((InteractsWithFiles) super.getWrappedDriver()).pullFile(remotePath);235 }236 @Override237 public byte[] pullFolder(String remotePath) {238 return ((InteractsWithFiles) super.getWrappedDriver()).pullFolder(remotePath);239 }240 @Override241 public Location location() {242 return ((LocationContext) super.getWrappedDriver()).location();243 }244 @Override245 public void setLocation(Location arg0) {246 ((LocationContext) super.getWrappedDriver()).setLocation(arg0);247 }248 @Override249 public WebElement findElementByAccessibilityId(String using) {250 return ((FindsByAccessibilityId) super.getWrappedDriver()).findElementByAccessibilityId(using);251 }252 @Override253 public List<WebElement> findElementsByAccessibilityId(String using) {254 return ((FindsByAccessibilityId) super.getWrappedDriver()).findElementsByAccessibilityId(using);255 }256 @Override257 public ScreenOrientation getOrientation() {258 return ((Rotatable) super.getWrappedDriver()).getOrientation();259 }260 @Override261 public void rotate(DeviceRotation deviceRotation) {262 ((Rotatable) super.getWrappedDriver()).rotate(deviceRotation);263 }264 @Override265 public DeviceRotation rotation() {266 return ((Rotatable) super.getWrappedDriver()).rotation();267 }268 @Override269 public void rotate(ScreenOrientation screenOrientation) {270 ((Rotatable) super.getWrappedDriver()).rotate(screenOrientation);271 }272 @Override273 public WebDriver context(String name) {274 return ((ContextAware) super.getWrappedDriver()).context(name);275 }276 @Override277 public String getContext() {278 return ((ContextAware) super.getWrappedDriver()).getContext();279 }280 @Override281 public Set<String> getContextHandles() {282 return ((ContextAware) super.getWrappedDriver()).getContextHandles();283 }284 @Override285 public Response execute(String driverCommand, Map parameters) {286 return ((MobileDriver) super.getWrappedDriver()).execute(driverCommand, parameters);287 }288 @Override289 public WebElement findElementByIosUIAutomation(String using) {290 return ((FindsByIosUIAutomation) super.getWrappedDriver()).findElementByIosUIAutomation(using);291 }292 @Override293 public List<WebElement> findElementsByIosUIAutomation(String using) {294 return ((FindsByIosUIAutomation) super.getWrappedDriver()).findElementsByIosUIAutomation(using);295 }296 @Override297 public WebElement findElementByAndroidUIAutomator(String using) {298 return ((FindsByAndroidUIAutomator) super.getWrappedDriver()).findElementByAndroidUIAutomator(using);299 }300 @Override301 public List<WebElement> findElementsByAndroidUIAutomator(String using) {302 return ((FindsByAndroidUIAutomator) super.getWrappedDriver()).findElementsByAndroidUIAutomator(using);303 }304 @Override305 public void startActivity(String appPackage, String appActivity, String appWaitPackage, String appWaitActivity,306 boolean stopApp) throws IllegalArgumentException {307 ((StartsActivity) super.getWrappedDriver()).startActivity(appPackage, appActivity, appWaitPackage,308 appWaitActivity, stopApp);309 }310 @Override311 public void startActivity(String appPackage, String appActivity, String appWaitPackage, String appWaitActivity) {312 ((StartsActivity) super.getWrappedDriver()).startActivity(appPackage, appActivity, appWaitPackage,313 appWaitActivity);314 }315 @Override316 public void startActivity(String appPackage, String appActivity) {317 ((StartsActivity) super.getWrappedDriver()).startActivity(appPackage, appActivity);318 }319 @Override320 public void startActivity(String appPackage, String appActivity, String appWaitPackage, String appWaitActivity,321 String intentAction, String intentCategory, String intentFlags, String intentOptionalArgs)322 throws IllegalArgumentException {323 ((StartsActivity) super.getWrappedDriver()).startActivity(appPackage, appActivity, appWaitPackage,324 appWaitActivity, intentAction, intentCategory, intentFlags, intentOptionalArgs);325 }326 @Override327 public void startActivity(String appPackage, String appActivity, String appWaitPackage, String appWaitActivity,328 String intentAction, String intentCategory, String intentFlags, String intentOptionalArgs, boolean stopApp)329 throws IllegalArgumentException {330 ((StartsActivity) super.getWrappedDriver()).startActivity(appPackage, appActivity, appWaitPackage,331 appWaitActivity, intentAction, intentCategory, intentFlags, intentOptionalArgs, stopApp);332 }333 @Override334 public void pushFile(String remotePath, byte[] base64Data) {335 ((PushesFiles) super.getWrappedDriver()).pushFile(remotePath, base64Data);336 }337 @Override338 public void pushFile(String remotePath, File file) throws IOException {339 ((PushesFiles) super.getWrappedDriver()).pushFile(remotePath, file);340 }341 @Override342 public TargetLocator switchTo() {343 return super.getWrappedDriver().switchTo();344 }345 @Override346 public Map<String, String> getAppStringMap() {347 return ((HasAppStrings) super.getWrappedDriver()).getAppStringMap();348 }349 @Override350 public Map<String, String> getAppStringMap(String language) {351 return ((HasAppStrings) super.getWrappedDriver()).getAppStringMap(language);352 }353 @Override354 public Map<String, String> getAppStringMap(String language, String stringFile) {355 return ((HasAppStrings) super.getWrappedDriver()).getAppStringMap(language, stringFile);356 }357 @Override358 public void pressKeyCode(int key) {359 ((AndroidDriver) super.getWrappedDriver()).longPressKeyCode(key);360 }361 @Override362 public void pressKeyCode(int key, Integer metastate) {363 ((AndroidDriver) super.getWrappedDriver()).pressKeyCode(key, metastate);364 }365 @Override366 public void longPressKeyCode(int key) {367 ((AndroidDriver) super.getWrappedDriver()).longPressKeyCode(key);368 }369 @Override370 public void longPressKeyCode(int key, Integer metastate) {371 ((AndroidDriver) super.getWrappedDriver()).longPressKeyCode(key, metastate);372 }373 @Override374 public void setConnection(Connection connection) {375 ((HasNetworkConnection) super.getWrappedDriver()).setConnection(connection);376 }377 @Override378 public Connection getConnection() {379 return ((HasNetworkConnection) super.getWrappedDriver()).getConnection();380 }381 @Override382 public String getId() {383 return UUID.randomUUID().toString();384 }385 /*386 * (non-Javadoc)387 * 388 * @see io.appium.java_client.ExecutesMethod#execute(java.lang.String)389 */390 @Override391 public Response execute(String arg0) {392 return ((ExecutesMethod) super.getWrappedDriver()).execute(arg0);393 }394 /*395 * (non-Javadoc)396 * 397 * @see398 * io.appium.java_client.FindsByFluentSelector#findElement(java.lang.String,399 * java.lang.String)400 */401 @Override402 public WebElement findElement(String arg0, String arg1) {403 return ((FindsByFluentSelector) super.getWrappedDriver()).findElement(arg0, arg1);404 }405 /*406 * (non-Javadoc)407 * 408 * @see io.appium.java_client.FindsByFluentSelector#findElements(java.lang.409 * String, java.lang.String)410 */411 @Override412 public List findElements(String arg0, String arg1) {413 ((FindsByFluentSelector) super.getWrappedDriver()).findElements(arg0, arg1);414 return null;415 }416 /*417 * (non-Javadoc)418 * 419 * @see io.appium.java_client.HasSessionDetails#isBrowser()420 */421 @Override422 public boolean isBrowser() {423 return ((HasSessionDetails) super.getWrappedDriver()).isBrowser();424 }425 /*426 * (non-Javadoc)427 * 428 * @see io.appium.java_client.PerformsActions#perform()429 */430 @Override431 public PerformsActions perform() {432 return ((PerformsActions) super.getWrappedDriver()).perform();433 }434}...

Full Screen

Full Screen

UpdateProfile.java

Source:UpdateProfile.java Github

copy

Full Screen

...103 // Get total width of seekbar104 int end = seekBar.getSize().getHeight();105 System.out.println("End point - " + end);106 act.press(PointOption.point(y + 100, start + 20))107 .moveTo(PointOption.point(y + 20, (end / 3) + start - 3)).release().perform();108 }109 110 while (!seekBarM.getAttribute("content-desc").equals(month)) {111 System.err.println(seekBarM.getAttribute("content-desc"));112 int start = seekBarM.getLocation().getY();113 System.out.println("Startpoint - " + start);114 // get location of seekBarM from top115 int y = seekBarM.getLocation().getX();116 System.out.println("Yaxis - " + y);117 // Get total width of seekBarM118 int end = seekBarM.getSize().getHeight();119 System.out.println("End point - " + end);120 act.press(PointOption.point(y + 100, start + 20))121 .moveTo(PointOption.point(y + 20, (end / 3) + start - 3)).release().perform();122 }123 124 while (!seekBarY.getAttribute("content-desc").equals(year)) {125 System.err.println(seekBarY.getAttribute("content-desc"));126 int start = seekBarY.getLocation().getY();127 System.out.println("Startpoint - " + start);128 // get location of seekBarY from top129 int y = seekBarY.getLocation().getX();130 System.out.println("Yaxis - " + y);131 // Get total width of seekBarY132 int end = seekBarY.getSize().getHeight();133 System.out.println("End point - " + end);134 act.press(PointOption.point(y + 100, start + 20))135 .moveTo(PointOption.point(y + 20, (end / 3) + start - 3)).release().perform();136 } 137 }138 139 public void click_OkDateButton() throws Exception {140 applyWait.waitForElementToBeClickable(okButton, 30).click();141 Screenshots.takeScreenshot(driver, "User clicked Ok button");142 test.log(Status.INFO, "User clicked OK button");143 Thread.sleep(9000L);144 }145 public void select_CountryDropdown(String input_Country) throws IOException {146 System.out.println("select country");147 applyWait.waitForElementToBeClickable(country_Dropdown, 30).click();148 if (input_Country.equalsIgnoreCase("India")) {149 applyWait.waitForElementToBeClickable(countryIndia_Dropdown, 30).click();150 Screenshots.takeScreenshot(driver, "User selected country as " + input_Country);151 test.log(Status.INFO, "User selected country as " + input_Country);152 } else if (input_Country.equalsIgnoreCase("Canada")) {153 applyWait.waitForElementToBeClickable(countryCanada_Dropdown, 30).click();154 Screenshots.takeScreenshot(driver, "User selected country as " + input_Country);155 test.log(Status.INFO, "User selected country as " + input_Country);156 }157 }158 159 public void enter_DefaultOcassion_Update_Profile() throws Exception {160 applyWait.waitForElementToBeClickable(defaultOcasion, 60).click();161 applyWait.waitForElementToBeClickable(deewaliOcasion, 60).click();162 applyWait.waitForElementToBeClickable(okButton, 60).click();163 Screenshots.takeScreenshot(driver, "User enter Default Occasion");164 test.log(Status.INFO, "User enter Default Occasion");165 Thread.sleep(9000L);166 }167 public void click_SaveButton() throws Exception {168 applyWait.waitForElementToBeClickable(save_Button, 60).click();169 Screenshots.takeScreenshot(driver, "User clicked save button");170 test.log(Status.INFO, "User clicked save button");171 Thread.sleep(9000L);172 }173 174 public void click_HamburgerMenu() throws Exception {175 applyWait.waitForElementToBeClickable(hamburger_Button, 60).click();176 Screenshots.takeScreenshot(driver, "User clicked hamburger button");177 test.log(Status.INFO, "User clicked hamburger button");178 Thread.sleep(9000L);179 }180 181 public void verifyUsername(String inputEmail) {182 applyWait.waitforElementToBeDisplayed(actualName, 60);183 WebElement text=actualName.findElement(By.xpath("//android.widget.ImageView[@index='0']"));184 String actualText=text.getAttribute("content-desc");185 String[] ch=actualText.split("\n");186 Assert.assertEquals(inputEmail, ch[1]);187 try {188 System.out.println("Email " + inputEmail + " is verified");189 Screenshots.takeScreenshot(driver,"Email " + inputEmail + " is verified");190 } catch (IOException e) {191 e.printStackTrace();192 }193 test.log(Status.INFO, "Email " + inputEmail + " is verified");194 }195 196 public void click_ChangePassword_Button() throws IOException {197 applyWait.waitForElementToBeClickable(changePassword_Button, 60).click();198 Screenshots.takeScreenshot(driver, "User clicked change password button");199 test.log(Status.INFO, "User clicked change password button");200 }201 public void enter_CurrentPassword(String input_CurrentPassword) throws IOException {202 applyWait.waitForElementToBeClickable(currentPassword_Textbox, 30).click();203 action.sendKeys(input_CurrentPassword).build().perform();204 Screenshots.takeScreenshot(driver, "User entered current password as " + input_CurrentPassword);205 test.log(Status.INFO, "User entered current password as " + input_CurrentPassword);206 }207 public void enter_NewPassword(String input_NewPassword) throws IOException {208 applyWait.waitForElementToBeClickable(newPassword_Textbox, 30).click();209 action.sendKeys(input_NewPassword).build().perform();210 Screenshots.takeScreenshot(driver, "User entered new password as " + input_NewPassword);211 test.log(Status.INFO, "User entered new password as " + input_NewPassword);212 }213 public void reEnter_NewPassword(String input_reEnter_NewPassword) throws IOException {214 applyWait.waitForElementToBeClickable(reEnternewPassword_Textbox, 30).click();215 action.sendKeys(input_reEnter_NewPassword).build().perform();216 Screenshots.takeScreenshot(driver, "User re entered new password as " + input_reEnter_NewPassword);217 test.log(Status.INFO, "User re entered new password as " + input_reEnter_NewPassword);218 }219 public void verify_PasswordUpdatedText(String message) throws IOException {220 applyWait.waitForElementToBeClickable(passwordSuccessfull_Text, 30);221 System.out.println("text " + passwordSuccessfull_Text.getText());222 if (passwordSuccessfull_Text.isEnabled() || passwordSuccessfull_Text.isDisplayed()) {223 Assert.assertTrue(true);224 Screenshots.takeScreenshot(driver, "Password updated text is " + message);225 test.log(Status.INFO, "Password updated text is " + message);226 } else {227 Assert.assertTrue(false);228 Screenshots.takeScreenshot(driver, "Password updated text is not displayed");229 test.log(Status.INFO, "Password updated text is not displayed");230 }231 }232 233 public void click_OKButton() throws IOException, InterruptedException {234 Thread.sleep(9000);235 act.tap(PointOption.point(360, 715)).perform();236 // applyWait.waitForElementToBeClickable(okButton, 30).click();237 // driver.navigate().back();238 Screenshots.takeScreenshot(driver, "User clicked ok button after filling all details");239 test.log(Status.INFO, "User clicked ok button after filling all details");240 try {241 Thread.sleep(3000);242 } catch (InterruptedException e) {243 e.printStackTrace();244 }245 }246 public void click_Logout_Button() throws IOException {247 applyWait.waitForElementToBeClickable(logout_Button, 30).click();248 Screenshots.takeScreenshot(driver, "User clicked logout button");249 test.log(Status.INFO, "User clicked logout button");...

Full Screen

Full Screen

TouchAction.java

Source:TouchAction.java Github

copy

Full Screen

...31 * Used for Webdriver 3 touch actions32 * See the Webriver 3 spec33 * https://dvcs.w3.org/hg/webdriver/raw-file/default/webdriver-spec.html34 * The flow is to chain individual touch actions into an entire gesture. e.g.35 * TouchAction action = new TouchAction(performsTouchActions);36 * action.press(element).waitAction(300).moveTo(element1).release().perform();37 * Calling perform() sends the action command to the Mobile Driver. Otherwise,38 * more and more actions can be chained.39 */40public class TouchAction<T extends TouchAction<T>> implements PerformsActions<T> {41 protected ImmutableList.Builder<ActionParameter> parameterBuilder;42 private PerformsTouchActions performsTouchActions;43 public TouchAction(PerformsTouchActions performsTouchActions) {44 this.performsTouchActions = checkNotNull(performsTouchActions);45 parameterBuilder = builder();46 }47 /**48 * Press action on the screen.49 *50 * @param pressOptions see {@link PointOption} and {@link ElementOption}.51 * @return this TouchAction, for chaining.52 */53 public T press(PointOption pressOptions) {54 parameterBuilder.add(new ActionParameter("press", pressOptions));55 //noinspection unchecked56 return (T) this;57 }58 /**59 * Remove the current touching implement from the screen (withdraw your touch).60 *61 * @return this TouchAction, for chaining.62 */63 public T release() {64 ActionParameter action = new ActionParameter("release");65 parameterBuilder.add(action);66 //noinspection unchecked67 return (T) this;68 }69 /**70 * Moves current touch to a new position.71 *72 * @param moveToOptions see {@link PointOption} and {@link ElementOption}73 * Important: some older Appium drivers releases have a bug when moveTo74 * coordinates are calculated as relative to the recent pointer position75 * in the chain instead of being absolute.76 * @see <a href="https://github.com/appium/appium/issues/7486">Appium Issue #748677 * for more details.</a>78 * @return this TouchAction, for chaining.79 */80 public T moveTo(PointOption moveToOptions) {81 ActionParameter action = new ActionParameter("moveTo", moveToOptions);82 parameterBuilder.add(action);83 return (T) this;84 }85 /**86 * Tap on an element.87 *88 * @param tapOptions see {@link TapOptions}.89 * @return this TouchAction, for chaining.90 */91 public T tap(TapOptions tapOptions) {92 ActionParameter action = new ActionParameter("tap", tapOptions);93 parameterBuilder.add(action);94 return (T) this;95 }96 /**97 * Tap on a position.98 *99 * @param tapOptions see {@link PointOption} and {@link ElementOption}100 * @return this TouchAction, for chaining.101 */102 public T tap(PointOption tapOptions) {103 ActionParameter action = new ActionParameter("tap", tapOptions);104 parameterBuilder.add(action);105 return (T) this;106 }107 /**108 * A wait action, used as a NOP in multi-chaining.109 *110 * @return this TouchAction, for chaining.111 */112 public T waitAction() {113 ActionParameter action = new ActionParameter("wait");114 parameterBuilder.add(action);115 //noinspection unchecked116 return (T) this;117 }118 /**119 * Waits for specified amount of time to pass before continue to next touch action.120 *121 * @param waitOptions see {@link WaitOptions}.122 * @return this TouchAction, for chaining.123 */124 public T waitAction(WaitOptions waitOptions) {125 ActionParameter action = new ActionParameter("wait", waitOptions);126 parameterBuilder.add(action);127 //noinspection unchecked128 return (T) this;129 }130 /**131 * Press and hold the at the center of an element until the context menu event has fired.132 *133 * @param longPressOptions see {@link LongPressOptions}.134 * @return this TouchAction, for chaining.135 */136 public T longPress(LongPressOptions longPressOptions) {137 ActionParameter action = new ActionParameter("longPress", longPressOptions);138 parameterBuilder.add(action);139 //noinspection unchecked140 return (T) this;141 }142 /**143 * Press and hold the at the center of an element until the context menu event has fired.144 *145 * @param longPressOptions see {@link PointOption} and {@link ElementOption}.146 * @return this TouchAction, for chaining.147 */148 public T longPress(PointOption longPressOptions) {149 ActionParameter action = new ActionParameter("longPress", longPressOptions);150 parameterBuilder.add(action);151 //noinspection unchecked152 return (T) this;153 }154 /**155 * Cancel this action, if it was partially completed by the performsTouchActions.156 */157 public void cancel() {158 ActionParameter action = new ActionParameter("cancel");159 parameterBuilder.add(action);160 this.perform();161 }162 /**163 * Perform this chain of actions on the performsTouchActions.164 *165 * @return this TouchAction, for possible segmented-touches.166 */167 public T perform() {168 performsTouchActions.performTouchAction(this);169 //noinspection unchecked170 return (T) this;171 }172 /**173 * Get the mjsonwp parameters for this Action.174 *175 * @return A map of parameters for this touch action to pass as part of mjsonwp.176 */177 protected Map<String, List<Object>> getParameters() {178 List<ActionParameter> actionList = parameterBuilder.build();179 return ImmutableMap.of("actions", actionList.stream()180 .map(ActionParameter::getParameterMap).collect(toList()));181 }182 /**...

Full Screen

Full Screen

Scrolling.java

Source:Scrolling.java Github

copy

Full Screen

...55 int startY = (int)(height*0.80);56 int endY = (int)(height*0.20);57 58 TouchAction action = new TouchAction(driver);59 action.press(PointOption.point(x, startY)).waitAction().moveTo(PointOption.point(x, endY)).release().perform();60 }61 62 63 64 public void scrollUp()65 {66 Dimension dimensions = driver.manage().window().getSize();67 int height = dimensions.getHeight();68 int width = dimensions.getWidth();69 // x will be same 70 int x = width/2;71 int startY = (int)(height*0.80);72 int endY = (int)(height*0.20);73 74 TouchAction action = new TouchAction(driver);75 action.press(PointOption.point(x, endY)).waitAction().moveTo(PointOption.point(x, startY)).release().perform();76 77 }78 79 80// public void scrollToElement(String elementName, boolean scrollDown){81// String listID = ((RemoteWebElement) driver.findElementByAndroidUIAutomator("new UiSelector().className(\"android.widget.ListView\")")).getId();82// String direction;83// if (scrollDown) {84// direction = "down";85// } else {86// direction = "up";87// }88// HashMap<String, String> scrollObject = new HashMap<String, String>();89// scrollObject.put("direction", direction);90// scrollObject.put("element", listID);91// scrollObject.put("text", elementName);92// driver.executeScript("mobile: scrollTo", scrollObject);93// }94 95 public void singleTap(AndroidElement element)96 {97 log.info("Single tap on element");98 TouchAction action = new TouchAction(driver);99 action.tap(tapOptions().withElement(element(element))).perform();100 }101 public void longPress(AndroidElement element,int time)102 {103 log.info("Long press on element");104 TouchAction action = new TouchAction(driver);105 action.longPress(longPressOptions().withElement(element(element)).withDuration(ofSeconds(time))).release().perform();106 }107 108 public void swipe(AndroidElement fromElement,AndroidElement toElement)109 {110 //Use long press first111 TouchAction action = new TouchAction(driver);112 log.info("swipping to given element");113 action.longPress(longPressOptions().withElement(element(fromElement)).withDuration(ofSeconds(2))).moveTo(element(toElement)).release().perform();114 }115}

Full Screen

Full Screen

MultiTouchAction.java

Source:MultiTouchAction.java Github

copy

Full Screen

...21 * See the Webriver 3 spec https://dvcs.w3.org/hg/webdriver/raw-file/default/webdriver-spec.html22 * The MultiTouchAction object is a collection of TouchAction objects23 * (remember that TouchAction objects are in turn, a chain of individual actions)24 * Add multiple TouchAction objects using the add() method.25 * When perform() method is called, all actions are sent to the performsTouchActions.26 * The performsTouchActions performs the first step of each TouchAction object simultaneously as a multi-touch27 * "execution group". Conceptually, the number of TouchAction objects added to the MultiTouchAction28 * is equal to the number of "fingers" or other appendages or tools touching the screen at the29 * same time as part of this multi-gesture. Then the performsTouchActions performs the second step of each30 * TouchAction object and another "execution group", and the third, and so on.31 * Using a waitAction() action within a TouchAction takes up one of the slots in an32 * "execution group", so these can be used to sync up complex actions.33 * Calling perform() sends the action command to the Mobile Driver. Otherwise, more and34 * more actions can be chained.35 */36public class MultiTouchAction implements PerformsActions<MultiTouchAction> {37 private ImmutableList.Builder<TouchAction> actions;38 private PerformsTouchActions performsTouchActions;39 public MultiTouchAction(PerformsTouchActions performsTouchActions) {40 this.performsTouchActions = performsTouchActions;41 actions = ImmutableList.builder();42 }43 /**44 * Add a TouchAction to this multi-touch gesture.45 *46 * @param action TouchAction to add to this gesture47 * @return This MultiTouchAction, for chaining48 */49 public MultiTouchAction add(TouchAction action) {50 actions.add(action);51 return this;52 }53 /**54 * Perform the multi-touch action on the mobile performsTouchActions.55 */56 public MultiTouchAction perform() {57 int size = actions.build().size();58 if (size > 1) {59 performsTouchActions.performMultiTouchAction(this);60 } else if (size == 1) {61 //android doesn't like having multi-touch actions with only a single TouchAction...62 performsTouchActions.performTouchAction(actions.build().get(0));63 } else {64 throw new MissingParameterException(65 "MultiTouch action must have at least one TouchAction "66 + "added before it can be performed");67 }68 return this;69 }70 protected ImmutableMap<String, ImmutableList<Object>> getParameters() {71 ImmutableList.Builder<Object> listOfActionChains = ImmutableList.builder();72 ImmutableList<TouchAction> touchActions = actions.build();73 touchActions.forEach(action -> {74 listOfActionChains.add(action.getParameters().get("actions"));75 });76 return ImmutableMap.of("actions", listOfActionChains.build());77 }78}...

Full Screen

Full Screen

BasePage.java

Source:BasePage.java Github

copy

Full Screen

...43 return elementos.size()>0;44 }45 46 public void tap(int x, int y) {47 //new TouchAction(getDriver()).tap(x,y).perform();48 49 (new TouchAction(getDriver())).tap(PointOption.point(x,y)).perform();50 }51 52 53 54 public void tocarCoordenada(int x, int y) {55 (new TouchAction(getDriver())).tap(PointOption.point(x,y)).perform();56 }57 58 public <T> void tocarCoodernada(T elemento, int x, int y) throws Exception {59 try {60 (new TouchAction(getDriver())).tap((TapOptions)TapOptions.tapOptions().withElement(ElementOption.element(this.retornaElementoMobile(elemento), x, y))).perform();61 } catch (Exception var6) {62 throw new Exception("Erro ao clicar por coordenadas", var6);63 } 64 }65 66 public <T> MobileElement retornaElementoMobile(T elemento) throws Exception{67 try {68 if(elemento instanceof By) {69 return (MobileElement)getDriver().findElement((By)elemento);70 }else {71 return elemento instanceof MobileBy ? (MobileElement)getDriver().findElement((MobileBy)elemento): (MobileElement)elemento;72 }73 }catch (NoSuchElementException var3) {74 throw new Exception("Não foi possivel localizar o lemento desejadona tela com a estrategia: " + elemento, var3);...

Full Screen

Full Screen

MobileName.java

Source:MobileName.java Github

copy

Full Screen

...30 Double end = size.getHeight() * 0.2;31 int endHeight = end.intValue();32 TouchAction tc = new TouchAction(driver);33 tc.press(PointOption.point(0, startHeight)).waitAction(WaitOptions.waitOptions(Duration.ofSeconds(3)))34 .moveTo(PointOption.point(0, endHeight)).release().perform();35 Double start1 = size.getHeight() * 0.2;36 int startHeight1 = start1.intValue();37 Double end1 = size.getHeight() * 0.5;38 int endHeight1 = end1.intValue();39 tc.press(PointOption.point(0, startHeight1)).waitAction(WaitOptions.waitOptions(Duration.ofSeconds(3)))40 .moveTo(PointOption.point(0, endHeight1)).release().perform();41 }42}...

Full Screen

Full Screen

PerformsActions.java

Source:PerformsActions.java Github

copy

Full Screen

...14 * limitations under the License.15 */16package io.appium.java_client;17public interface PerformsActions<T extends PerformsActions<T>> {18 T perform();19}...

Full Screen

Full Screen

perform

Using AI Code Generation

copy

Full Screen

1import io.appium.java_client.PerformsActions;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 java.util.concurrent.TimeUnit;8import org.openqa.selenium.WebElement;9import org.openqa.selenium.remote.DesiredCapabilities;10import org.testng.annotations.Test;11public class Swipe {12public void swipe() throws MalformedURLException, InterruptedException {13DesiredCapabilities dc = new DesiredCapabilities();14dc.setCapability("deviceName", "Android Emulator");15dc.setCapability("platformName", "Android");16dc.setCapability("platformVersion", "4.4.2");17dc.setCapability("appPackage", "com.android.calculator2");18dc.setCapability("appActivity", "com.android.calculator2.Calculator");

Full Screen

Full Screen

perform

Using AI Code Generation

copy

Full Screen

1public class AppiumTest {2 public static void main(String[] args) throws MalformedURLException, InterruptedException {3 DesiredCapabilities capabilities = new DesiredCapabilities();4 capabilities.setCapability("deviceName", "emulator-5554");5 capabilities.setCapability("platformName", "Android");6 capabilities.setCapability("platformVersion", "5.0.2");7 capabilities.setCapability("appPackage", "com.android.calculator2");8 capabilities.setCapability("appActivity", "com.android.calculator2.Calculator");9 capabilities.setCapability("noReset", true);10 capabilities.setCapability("fullReset", false);11 capabilities.setCapability("newCommandTimeout", 300);

Full Screen

Full Screen

perform

Using AI Code Generation

copy

Full Screen

1Actions actions = new Actions(driver);2TouchAction touchAction = new TouchAction(driver);3MultiTouchAction multiTouchAction = new MultiTouchAction(driver);4Actions actions = new Actions(driver);5TouchAction touchAction = new TouchAction(driver);6MultiTouchAction multiTouchAction = new MultiTouchAction(driver);7Actions actions = new Actions(driver);8TouchAction touchAction = new TouchAction(driver);9MultiTouchAction multiTouchAction = new MultiTouchAction(driver);10Actions actions = new Actions(driver);11TouchAction touchAction = new TouchAction(driver);12MultiTouchAction multiTouchAction = new MultiTouchAction(driver);13Actions actions = new Actions(driver);14TouchAction touchAction = new TouchAction(driver);15MultiTouchAction multiTouchAction = new MultiTouchAction(driver);16Actions actions = new Actions(driver);17TouchAction touchAction = new TouchAction(driver);18MultiTouchAction multiTouchAction = new MultiTouchAction(driver);19Actions actions = new Actions(driver);20TouchAction touchAction = new TouchAction(driver);

Full Screen

Full Screen

perform

Using AI Code Generation

copy

Full Screen

1Actions builder = new Actions(driver);2builder.moveToElement(element).perform();3action.tap(element: element).perform4action = TouchAction(driver)5action.tap(element).perform()6action = new wd.TouchAction(driver);7action.tap(element).perform();8action := appium.NewTapAction()9action.Tap(element).Perform()10$tap = new Appium\WebDriver\TouchAction($driver);11$tap->tap($element)->perform();12let action = AppiumTouchAction(driver)13action.tap(element: element).perform()14var action = new TouchAction(driver);15action.Tap(element).Perform();16var action = new TouchAction(driver);17action.Tap(element).Perform();18var action = new TouchAction(driver);19action.Tap(element).Perform();20var action = new TouchAction(driver);21action.Tap(element).Perform();22var action = new TouchAction(driver);23action.Tap(element).Perform();24var action = new TouchAction(driver);25action.Tap(element).Perform();26var action = new TouchAction(driver);27action.Tap(element).Perform();

Full Screen

Full Screen

perform

Using AI Code Generation

copy

Full Screen

1import io.appium.java_client.TouchAction;2import io.appium.java_client.android.AndroidDriver;3import io.appium.java_client.android.AndroidElement;4import io.appium.java_client.touch.offset.ElementOption;5import java.net.MalformedURLException;6import java.net.URL;7import org.openqa.selenium.By;8import org.openqa.selenium.WebElement;9import org.openqa.selenium.remote.DesiredCapabilities;10import org.testng.annotations.BeforeClass;11import org.testng.annotations.Test;12public class MouseOver {13 private AndroidDriver<AndroidElement> driver;14 public void setUp() throws MalformedURLException {15 DesiredCapabilities desiredCapabilities = new DesiredCapabilities();16 desiredCapabilities.setCapability("platformName", "Android");17 desiredCapabilities.setCapability("deviceName", "emulator-5554");18 desiredCapabilities.setCapability("automationName", "UiAutomator2");19 desiredCapabilities.setCapability("appPackage", "com.androidsample.generalstore");20 desiredCapabilities.setCapability("appActivity", ".SplashActivity");21 driver = new AndroidDriver<AndroidElement>(remoteUrl, desiredCapabilities);22 }23 public void test() {24 driver.findElement(By.id("com.androidsample.generalstore:id/nameField")).sendKeys("Hello");25 driver.hideKeyboard();26 driver.findElement(By.id("com.androidsample.generalstore:id/radioFemale")).click();27 driver.findElement(By.id("com.androidsample.generalstore:id/btnLetsShop")).click();28 TouchAction t = new TouchAction(driver);29 t.moveTo(ElementOption.element(addToCart)).perform();30 }31}32const wdio = require('webdriverio');33const opts = {34 capabilities: {35 }36};37async function main() {38 const driver = await wdio.remote(opts);

Full Screen

Full Screen

perform

Using AI Code Generation

copy

Full Screen

1PerformsActions actions = (PerformsActions) driver;2TouchAction touchAction = new TouchAction(driver);3actions.perform(touchAction.doubleTap(element).release().perform());4PerformsActions actions = (PerformsActions) driver;5TouchAction touchAction = new TouchAction(driver);6actions.perform(touchAction.longPress(element).release().perform());7PerformsActions actions = (PerformsActions) driver;8TouchAction touchAction = new TouchAction(driver);9actions.perform(touchAction.press(element).release().perform());10PerformsActions actions = (PerformsActions) driver;11TouchAction touchAction = new TouchAction(driver);12actions.perform(touchAction.tap(element).release().perform());13PerformsActions actions = (PerformsActions) driver;14TouchAction touchAction = new TouchAction(driver);15actions.perform(touchAction.waitAction(1000).perform());

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 PerformsActions

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful