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)

  • 相关阅读:
    ASP.NET Web Form(八)
    ASP.NET Web Form(八)
    软考知识点总结
    软考知识点总结
    c# 引用外部dll
    c# 引用外部dll
    ORA600 [Kcbz_check_objd_typ_1] Running a Job (Doc ID 785899.1)
    oracle创建em
    1918: 等值数目
    1917: 支配值数目
  • 原文地址:https://www.cnblogs.com/kenD/p/12449948.html
Copyright © 2011-2022 走看看