swipe slide operation

1.swipe () slide Usage
  • Swipe(x1,y1,x2,y2,duration)
  • x1- x coordinate starts sliding, y1- Y coordinate begins to slide
  • x2- end point coordinates x, y coordinates of the end point Y2 -
  • duration slip event (default 5 ms)
# Coding. 8 = UTF- 

from appium Import the webdriver 

Import Time 

# define the parameters necessary to start the device 
desired_caps = {
 " PlatformName " : " the Android " , # phone system 
" deviceName " : " 127.0.0.1:62001 " , # device name, in dos get input adb devices 
" platformVersion " : " 5.1.1 " , # phone system version 
" appPackage " : "com.yw.yzz" , # Package name (# dos xxx.apk enter under the existing folder, enter aapt dump badging xxx.apk get) 
" appActivity " : " com.yw.yzz.biz.splash.SplashActivity " , # APP activities (# xxx.apk into the file existed in the dos folder, enter aapt dump badging xxx.apk get) 
" unicodeKeyboard " : " True " , # use appium input method, support Chinese and hide the keyboard 
" resetKeyboard " : " True " , # input device reset back to the default input France and France 
" NoReset " : " True "#appium start automatically cleared when the inside of the app app data, noReset = True is to start the app does not clear data 
} 
Driver = webdriver.Remote ( " http://127.0.0.1:4723/wd/hub " , desired_caps)
 # Code and script server communication is carried out by http://127.0.0.1:4723/wd/hub (fixed format) 

the time.sleep ( . 1 )
 Print (driver.get_window_size ()) # high and wide screen printing 
time.sleep (2 ) 

# sliding guide page left 
Y = 0
 the while Y <. 3 : 
    driver.swipe ( 350, 900, 350, 100, 1000 ) 
    the time.sleep ( . 1 ) 
    Y + =. 1 
    the time.sleep ( . 1 )
driver.find_element_by_id("com.yw.yzz:id/btn_open").click()
time.sleep(4)
driver.find_element_by_id("com.yw.yzz:id/recyclerview").click()
driver.find_element_by_id("com.yw.yzz:id/recyclerview").click()
driver.find_element_by_id("com.yw.yzz:id/recyclerview").click()
driver.find_element_by_id("com.yw.yzz:id/seting_tab").click()
driver.find_element_by_id("com.yw.yzz:id/fragment_my_nickname").click()
driver.find_element_by_id("com.yw.yzz:id/login_name").send_keys("17779828883")
driver.find_element_by_id("com.yw.yzz:id/login_identify_code").send_keys("123456")
driver.find_element_by_id("com.yw.yzz:id/btn_login").click()

 

#coding=utf-8

from appium import webdriver
from time import sleep

caps = {
  "platformName": "Android",
  "deviceName": "127.0.0.1:62001",
  "platformVersion": "5.1.1",
  "appPackage": "com.yw.yzz",
  "appActivity": "com.yw.yzz.biz.splash.SplashActivity",
  "unicodeKeyboard": "True",
  "resetKeyboard": "True"
  # "noReset": "True"
}
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',caps)

def size():
   x=driver.get_window_size()["width"]#获取当前屏幕的宽
   y=driver.get_window_size()["height"]#Get current screen high 
   return (X, Y) 

# slide- 
DEF up (T): 
    SZ = size () 
    X1 = int (SZ [0] * 0.5 ) 
    Y1 = int (SZ [. 1] * 0.9 ) 
    Y2 = int (SZ [. 1] * 0.2 ) 
    driver.swipe (X1, Y1, X1, Y2, T) 
    SLEEP ( . 1 )
     return Driver 

# decline 
DEF Down (T): 
    SZ = size () 
    X1 = int (SZ [0] * 0.5 ) 
    Y1 = int (SZ [. 1] * 0.2 ) 
    Y2 = int (SZ [. 1] * 0.9 ) 
    driver.swipe (X1, Y1, X1, Y2, T) 
    SLEEP ( . 1)
    return driver

#左滑
def left(t):
    sz=size()
    x1=int(sz[0]*0.9)
    x2=int(sz[0]*0.2)
    y1=int(sz[1]*0.5)
    driver.swipe(x1,y1,x2,y1,t)
    sleep(1)
    return driver

#右滑
def right(t):
    sz=size()
    x1=int(sz[0]*0.2)
    x2=int(sz[0]*0.9)
    y1=int(sz[1]*0.5)
    driver.swipe(x1,y1,x2,y1,t)
    sleep(1)
    return driver

 

 

 

Guess you like

Origin www.cnblogs.com/Mr-ZY/p/12028470.html