Appium 자동화 상하좌우 스크롤 하기
2016. 3. 23. 15:52
반응형
swipe를 이용한 상하좌우 스크롤 및 스크롤 새로고침 구현
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | import io.appium.java_client.AppiumDriver; import io.appium.java_client.TouchAction; import io.appium.java_client.android.AndroidDriver; import java.net.MalformedURLException; import java.net.URL; import java.util.List; import java.util.NoSuchElementException; import org.openqa.selenium.By; import org.openqa.selenium.Dimension; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.DesiredCapabilities; //import org.junit.Test; import org.testng.annotations.Test; public class Utilities extends AndroidDriver<WebElement> implements TakesScreenshot { Dimension size = manage().window().getSize(); /** * 위로 스크롤 */ public void scrollUp() throws Exception { Thread.sleep(2000); int starty = (int) (size.height * 0.80); int endy = (int) (size.height * 0.20); int startx = size.width / 2; System.out.println("startx = " + startx + " ,endy = " + endy + " , starty = " + starty); //올리기 this.swipe(startx, endy, startx, starty, 0); Thread.sleep(2000); } /** * 아래로 스크롤 */ public void scrollDown() throws Exception { Thread.sleep(2000); int starty = (int) (size.height * 0.80); int endy = (int) (size.height * 0.20); int startx = size.width / 2; // System.out.println("startx = " + startx + " ,endy = " + endy + " , starty = " + starty); //내려가기 swipe(startx, starty, startx, endy, 0); Thread.sleep(2000); } /** * 스크롤 새로고침 */ public void pullToRefresh() throws Exception { Thread.sleep(1000); int starty = (int) (size.height * 0.5); int endy = (int) (size.height * 0.9); int startx = (int) (size.width*0.01); // System.out.println("startx = " + startx + " ,endy = " + endy + " , starty = " + starty); //내려가기 swipe(startx, starty, startx, endy, 0); Thread.sleep(2000); } /** * 오른쪽에서 왼쪽으로 Swipe */ public void swipeToLeft() throws Exception { Thread.sleep(2000); int starty = (int) (size.width * 0.80); int endx = (int) (size.width * 0.20); int startx = size.height / 2; swipe(startx, starty, endx, starty, 0); Thread.sleep(2000); } /** * 왼쪽에서 오른쪽으로 Swipe */ public void swipeToRight() throws Exception { Thread.sleep(2000); int starty = (int) (size.width * 0.80); int endx = (int) (size.width * 0.20); int startx = size.height / 2; swipe(endx, starty, startx, starty, 0); Thread.sleep(2000); } } | cs |
반응형
'지식메모 > 자동화' 카테고리의 다른 글
테스터로서 느낀 4가지 실수들 (0) | 2016.06.14 |
---|---|
appium 에서 특정영역을 좌우로 swipe 하기 (2) | 2016.05.23 |
Robotium API 기능 알아보기 (0) | 2016.02.18 |
로보티움 튜토리얼 실행해보기 (0) | 2015.09.04 |
Selenium & Webdriver 자동화 테스트 예제 - Naver 지식인 (크롬 브라우저) (0) | 2015.01.23 |