Appium Appium 1.6.3 python 3,怎么获取 toast 消息?

huiyu · April 21, 2017 · Last by 陈子昂 replied at April 21, 2017 · 1717 hits

我在网站上面看见 1.6.3 可以支持读取 toast?但是我没有找到方法。
https://testerhome.com/topics/6685
https://testerhome.com/topics/7144
https://testerhome.com/topics/6009
这些帖子我都看了,还是没有看明白。

我的目的是,在 APP 登录页面判断 ‘用户名密码错误’ 的 toast 是否存在。
我用了很多方法都没有实现。

共收到 3 条回复 时间 点赞

你要注意实际上不是去获取而是能够判断有没有对应的 toast 元素了,换句话说是能够根据你对应 toast 的内容去检查是否有这个元素。

huiyu #2 · April 21, 2017 Author
gz 回复
def find_toast(self,message,timeout,poll_frequency,driver):
        message = '//*[@text=\'{}\']'.format(message)
        element = WebDriverWait(driver,timeout,poll_frequency).until(expected_conditions.presence_of_element_located((By.XPATH,message)))
        print (element)
```python

这个函数是查询对应的toast然后打印出来吧但是为什么我运行失败了呢  1.6.4+pyhon3
 "F:\001\RE_Testcase.py", line 194, in guide
    self.find_toast(u'用户名密码错误',10,0.5,self.driver)
  File "F:\001\RE_Testcase.py", line 72, in find_toast
    element = WebDriverWait(driver,timeout,poll_frequency).until(expected_conditions.presence_of_element_located((By.XPATH,message)))
  File "F:\001\selenium\webdriver\support\wait.py", line 80, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:

格式上稍微注意下啊
appium 的 @Lihuazhang

huiyu 关闭了讨论 22 Apr 18:12
需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up