• python_api操作之swipe和九宫格


    一。appium常用API操作

    1.API操作:

      - driver.start_activity() 跳转到指定的页面

      - swipe(), 滑动

        -例子:

        屏幕,宽 800, 高 900
        790, 450, 10, 450
        driver.swipe(790, 450, 10, 450)

        问题在于我传的坐标到底应该是多少。
        取决于屏幕的宽度
        先获取屏幕宽度 width, height
        向左滑,我的起始点 x 坐标, width * 0.9, height * 0.5 结束点 x 坐标, 0.1, height *0.5
        结束点的 height 和 起始点保持一致。

        # 获取屏幕的宽度。
        size = driver.get_window_size()
        # 得到一个字典
        width = size["width"]
        height = size["height"]
        # 向左滑动
        # 这个就是滑动的标准操作
        driver.swipe(
        start_x= width * 0.9,
        start_y= height * 0.5,
        end_x= width * 0.1,
        end_y= height * 0.5
          )

      - 触屏操作
      - 多指操作 (放大,缩小)
      - 键盘输入()

    2.app元素定位(建议元素使用的先后顺序):

      - ID
      - content-desc ===> driver.find_element_by_accessibility_id()
      - uiautomator ===> driver.find_element_by_android_uiautomator()
      - xpath

    3.TouchAction触碰动作(封装了常用操作,通过链式调用进行使用):

      - action = TouchAction()
      - action.press().wait().move_to().wait().move_to().realease().perform()
      - 链式调用

    4.九宫格操作:

      - press 九宫格的第一个格子, 坐标确认。
      - wait
      - move_to 第二
      - wait
      - move_to 第三个
      - wait
      - move_to
      - wait
      - release()
      - perform()

  • 相关阅读:
    c++中sort等算法中比较操作的规则
    数据结构(c++)(1)-- 栈
    Problem 10: Summation of primes
    Problem 9: Special Pythagorean triplet
    Problem 7: 10001st prime
    Problem 8: Largest product in a series
    Problem 5: Smallest multiple
    Problem 6: Sum square difference
    Problem 4: Largest palindrome product
    Problem 3: Largest prime factor
  • 原文地址:https://www.cnblogs.com/newsss/p/13493538.html
Copyright © 2020-2023  润新知