最近这段时间比较忙好久没跟朋友们一起分享技术话题了,今天接着上一篇的Robot继续跟大家分享Robotframework-Appiumlibrary通过索引定位元素。
1.应用场景
做Android自动化测试的朋友肯定遇到过具有相同ID或Class的无从操作的时候,很多人会想到加个索引呀,没错索引确实能解决这个问题,但是Robotframework-Appiumlibrary是不支持索引的,这就需要我们进行扩展,比如下面的微信表情,全部是相同的ID。
2.定位代码
#通常我们用这个方法来操作点击元素
def click_element(self, locator):
"""Click element identified by `locator`.
Key attributes for arbitrary elements are `index` and `name`. See
`introduction` for details about locating elements.
"""
self._info("