Appium Slide Function: Swipe

Source: Internet
Author: User
Tags appium

Appium Handling Sliding method is swipe

SlideApi:Swipe(int start x,int start y,int end x,int y,duration)
Explanation:
int start X-Started to slidexcoordinates;
int start Y-Started to slideycoordinates;
int end X-end pointxcoordinates;
int End Y-end pointycoordinates; 
Durationsliding time (default5milliseconds).

the upper-left corner of the screen is the starting point, with coordinates (0,0), the start point to the right and the Y axis, and the starting point is X Shaft

, the login button start and end coordinates are (1716) and (432,1860 )

Make Apppium better compatible with different resolution devices, get the screen resolution before performing the swipe

1. Screen resolution

according to the screen resolution is the end point coordinates, such as your phone resolution 1080*1920, then the phone coordinate system end is (1080*1920)

2. According to the code to get

int width = driver.manage (). window (). GetSize (). width;   int height = driver.manage (). window (). GetSize (). Height;  

Now introduce the parameters within the custom method

Driver(The appiumdriver object is passed in)

During(here is the number of milliseconds to fill, the smaller the number of milliseconds, the faster the speed of the slide- generally set in the 500~1000, if you want to quickly slide that can be set smaller)

Num(is the number of slides that are only sliding, such as multiple pictures in a photo album to test what slide or swipe to the bottom of the list.) Just enter the number of times on the line)

Gosleep () is their own encapsulated thread.sleep method, do not understand the following links http://www.cnblogs.com/bamu/archive/2013 /03/14/2959663.html

Top Slip Swipetoup

 PublicStatic voidSwipetoup (appiumdriver<webelement> driver,intDuringintnum) {      intwidth =driver.manage (). window (). GetSize (). width; intHeight =driver.manage (). window (). GetSize (). Height;  for(inti = 0; i < num; i++) {driver.swipe (width/2, Height * 3/4, WIDTH/2, HEIGHT/4, Duri gosleep (3); }  }  

Swipetodown drop down

 PublicStaticvoidSwipetodown (appiumdriver<webelement> driver,intDuringintnum) {  intwidth =driver.manage (). window (). GetSize (). width; intHeight =driver.manage (). window (). GetSize (). Height; System.out.println (width); System.out.println (height);  for(inti = 0; i < num; i++) {  Driver.swipe (WIDTH/2, HEIGHT/4, WIDTH/2, Height * 3/4, during); Gosleep (3);     }  }

Swipetoleft Slide Left

 PublicStaticvoidSwipetoleft (appiumdriver<webelement> driver,intDuringintnum) {      intwidth =driver.manage (). window (). GetSize (). width; intHeight =driver.manage (). window (). GetSize (). Height;  for(inti = 0; i < num; i++) {driver.swipe (width* 3/4, HEIGHT/2, WIDTH/4, HEIGHT/2, during); Gosleep (3); }  } 

Swipetoleft Slide Left

 PublicStaticvoidSwipetoright (appiumdriver<webelement> driver,intDuringintnum) {      intwidth =driver.manage (). window (). GetSize (). width; intHeight =driver.manage (). window (). GetSize (). Height;  for(inti = 0; i < num; i++) {driver.swipe (width/4, HEIGHT/2, Width * 3/4, HEIGHT/2, during); Gosleep (3); }  }

Appium Slide Function: Swipe

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.