Appium定位

时间:2020-10-02 16:59:39   收藏:0   阅读:37

定位方式

ID定位

content-desc定位

xpath定位

定位工具

Appium desktop定位

每次定位都需要先执行脚本,到达定位控件的上下文。
可参考:https://www.cnblogs.com/Uni-Hoang/p/13734384.html

uiautomatorviewer

uiautomatorviewer是android SDK自带的工具,只适用与android定位。通过截屏并分析XML布局文件的方式,为用户提供控件信息查看服务。该工具位于SDK目录下的tools\bin子目录下。可以看到,它是通过bat文件启动的。

技术分享图片

def test_getPrice(self):
        self.driver.find_element(MobileBy.ID,"tv_search").click()     # MobileBy继承By
        self.driver.find_element(MobileBy.ID,"search_input_text").send_keys("阿里巴巴")
        self.driver.find_element(MobileBy.ID,"name").click()  # 第一张图片定位
        # 获取价格,转换为float类型进行断言
        assert float(self.driver.find_element(MobileBy.ID, "current_price").text) > 250  # 第二张图片定位

遇到的问题

原文:https://www.cnblogs.com/Uni-Hoang/p/13761925.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!