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)

  • 相关阅读:
    小明铺路
    Python库-BeautifulSoup
    Python库-re(正则表达式)
    cpp分解质因数
    cf Double Happiness(判断是否为素数且为4k+1型)
    ACM-世界岛旅行
    C#(.Net)中调用Sql sever汉字字符串显示为?问号
    如何配置Python环境
    记账软件——第三天
    记账软件——第二天
  • 原文地址:https://www.cnblogs.com/kenD/p/12449948.html
Copyright © 2011-2022 走看看