appium--滑動和拖拽
阿新 • • 發佈:2020-11-13
import time from appium import webdriver desired_caps = dict() desired_caps['deviceName'] = '192.168.234.104:5555' desired_caps['platformName'] = 'android' desired_caps['platformVersion'] = '5' desired_caps['appPackage'] = 'com.android.settings' # 設定的包名 desired_caps['appActivity'] = '.Settings' # 設定的介面名desired_caps['unicodeKeyboard'] = True desired_caps['resetKeyboard'] = True driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_capabilities=desired_caps) # ----swipe----對應引數為開始點的x座標,y座標,結束點的x座標,y座標,duration持續時間(ms) # driver.swipe(1050, 1000, 1050, 100, duration=3000) # ----scroll----從一個元素位置滑動到另一個元素位置,帶慣性# 從'應用'滑動到'更多' ele1 = driver.find_element_by_android_uiautomator('text("應用")') ele2 = driver.find_element_by_android_uiautomator('text("更多")') # driver.scroll(ele1, ele2) # ----drag_and_drop---從一個元素滑動到另一個元素,第二個元素替換第一個元素原本螢幕上的位置,無慣性 ele3 = driver.find_element_by_android_uiautomator('text("安全")') ele4= driver.find_element_by_android_uiautomator('text("藍芽")') driver.drag_and_drop(ele3, ele4) time.sleep(5) driver.quit()