appium重新封装后,取一组元素之后显示不是列表类型的乌龙(copy有风险,paste需谨慎)

appium重新封装后的一组元素(这是错误的):

# 获取一组元素
    def find_elements(self, loc, timeout=10, poll=0.5):
        return WebDriverWait(self.driver, timeout, poll).until(lambda x: x.find_element(*loc)

使用该函数取一组元素时,打印类型显示不是列表,原因是在lambda函数里的find_element少了一个s

因找的是单个元素,不是一组,导致不是列表类型

封装正确如下:

# 获取一组元素
    def find_elements(self, loc, timeout=10, poll=0.5):
        return WebDriverWait(self.driver, timeout, poll).until(lambda x: x.find_elements(*loc)
原文地址:https://www.cnblogs.com/zhaoquanmo/p/11022005.html