51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

查看: 1770|回复: 0

RF+Appium 滑屏问题:APP兼容性测试

[复制链接]
  • TA的每日心情
    无聊
    昨天 09:21
  • 签到天数: 398 天

    连续签到: 4 天

    [LV.9]测试副司令

    发表于 2018-12-12 16:03:19 | 显示全部楼层 |阅读模式
    本帖最后由 测试积点老人 于 2018-12-12 16:08 编辑

    用例:模糊搜索
    • 打开APP(未登录账户)
    • 进入首页-搜索
    • 点击热门关键字搜索
    • 检测搜索到的卡是否包含Excel表中所有数据



    一、 说明
    • 数据源

                数据驱动以 Read Column From Excel 方式实现,关于详情请查看个人博客数据驱动部分。

    • 滑屏问题

                 因为模糊搜索结果较多,一屏无法显示所有的结果,需要滑屏;
                 而不同型号的手机有不同的分辨率,关键字:swipe 有时无法精确定位;
                 手机型号选择,根据公司需求可以选择主流手机进行测试。

    二、关键字:APP_Get_All_Search_Courses




    滑屏方式:
    • 封装关键字:APP_Sliding_Screen_by_resolution
      RIDE关键字 swipe 有时因为分辨率不同,无法精确定位。所以,以屏幕分辨率封装关键字。
    • RIDE关键字:swipe

    思路:
    • 查找唯一 的 resource-id(这个需要和开发确定。如果没有唯一 的 resource-id,通过xpath实现);
    • 例如,需要定位 5 个控件,有些机型一个屏幕只能显示 4 个;
    • 通过 index 定位,先找到 4 个控件;
    • 再通过 swipe 滑动屏幕,查找结果
    • 全局参数:U_ANDROID_DEVICES_TYPE 区分不同机型;例如,华为手机


    三、关键字:APP_Sliding_Screen_by_resolution




    方案:先通过 Get Window Height & Get Window Width 获取屏幕高和宽,再通过百分比实现滑屏。

    四、关键字:swipe_by_percent

    库更新:Appiumlibrary (1.4.5)
    最近 Appiumlibrary 发布新版本,已经封装了通过分辨率来滑动屏幕的关键字 swipe_by_percent,和 APP_Sliding_Screen_by_resolution 实现的原理一样。
    源码:
    1. def swipe_by_percent(self, start_x, start_y, end_x, end_y, duration=1000):
    2.         """
    3.         Swipe from one percent of the screen to another percent, for an optional duration.
    4.         Normal swipe fails to scale for different screen resolutions, this can be avoided using percent.

    5.         Args:
    6.          - start_x - x-percent at which to start
    7.          - start_y - y-percent at which to start
    8.          - end_x - x-percent distance from start_x at which to stop
    9.          - end_y - y-percent distance from start_y at which to stop
    10.          - duration - (optional) time to take the swipe, in ms.

    11.         Usage:
    12.         | Swipe By Percent | 90 | 50 | 10 | 50 | # Swipes screen from right to left. |

    13.         _*NOTE: *_
    14.         This also considers swipe acts different between iOS and Android.

    15.         New in AppiumLibrary 1.4.5
    16.         """
    17.         width = self.get_window_width()
    18.         height = self.get_window_height()
    19.         x_start = float(start_x) / 100 * width
    20.         x_end = float(end_x) / 100 * width
    21.         y_start = float(start_y) / 100 * height
    22.         y_end = float(end_y) / 100 * height
    23.         x_offset = x_end - x_start
    24.         y_offset = y_end - y_start
    25.         platform = self._get_platform()
    26.         if platform == 'android':
    27.             self.swipe(x_start, y_start, x_end, y_end, duration)
    28.         else:
    29.             self.swipe(x_start, y_start, x_offset, y_offset, duration)
    复制代码





    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有帐号?(注-册)加入51Testing

    x
    回复

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-4-19 01:10 , Processed in 0.065111 second(s), 25 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表