zoukankan      html  css  js  c++  java
  • Appium使用

    初始化
    # Android environment


    from appium import webdriver

    desired_caps = {}
    desired_caps['platformName'] = 'Android'
    desired_caps['platformVersion'] = '8.1'
    desired_caps['automationName'] = 'uiautomator2'
    desired_caps['deviceName'] = 'Android Emulator'
    desired_caps['app'] = PATH('../../../apps/selendroid-test-app.apk')

    self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

    # 查找元素
    el = self.driver.find_element_by_android_uiautomator('new UiSelector().description("Animation")')
    els = self.driver.find_elements_by_android_uiautomator('new UiSelector().clickable(true)')

    el = self.driver.find_element_by_android_viewtag('a tag name')
    els = self.driver.find_elements_by_android_viewtag('a tag name')


    # 点击
    tap()
    click()

    # 动作链
    el = self.driver.find_element_by_accessibility_id('Animation')
    action = TouchAction(self.driver)
    action.tap(el).perform()


    # 多动作
    els = self.driver.find_elements_by_class_name('listView')
    a1 = TouchAction()
    a1.press(els[0])
    .move_to(x=10, y=0).move_to(x=10, y=-75).move_to(x=10, y=-600).release()

    a2 = TouchAction()
    a2.press(els[1])
    .move_to(x=10, y=10).move_to(x=10, y=-300).move_to(x=10, y=-600).release()

    ma = MultiAction(self.driver, els[0])
    ma.add(a1, a2)
    ma.perform();


    # 拖动
    driver.swipe

    FLICK_START_X = 300
    FLICK_START_Y = 300
    FLICK_DISTANCE = 700

    def scroll(self):
    while True:
    self.driver.swipe(FLICK_START_X, FLICK_START_Y + FLICK_DISTANCE, FLICK_START_X, FLICK_START_Y)
    sleep(2)

  • 相关阅读:
    BZOJ 1391: [Ceoi2008]order
    BZOJ 4504: K个串
    2019 年百度之星·程序设计大赛
    POJ 2398 Toy Storage (二分 叉积)
    POJ 2318 TOYS (二分 叉积)
    HDU 6697 Closest Pair of Segments (计算几何 暴力)
    HDU 6695 Welcome Party (贪心)
    HDU 6693 Valentine's Day (概率)
    HDU 6590 Code (判断凸包相交)
    POJ 3805 Separate Points (判断凸包相交)
  • 原文地址:https://www.cnblogs.com/kenD/p/12449948.html
Copyright © 2011-2022 走看看