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)

  • 相关阅读:
    Beef McNuggets USACO 4.1(数论公约数问题+背包阵亡)
    Raucous Rockers USACO 3.4 (dp背包?)
    Electric Fence USACO 3.4
    大雾....
    American Heritage USACO 3.4 (二叉树前序中序求后序)
    Closed Fences USACO 3.4(阵亡)
    cvte酱油一把
    算法导论之计算几何学小记 33.1
    A Game USACO 3.3 (DP阵亡)
    [bx]和loop指令
  • 原文地址:https://www.cnblogs.com/kenD/p/12449948.html
Copyright © 2011-2022 走看看