为了账号安全,请及时绑定邮箱和手机立即绑定

appium 用automator2定位toast提示,报错

/ 猿问

appium 用automator2定位toast提示,报错


# coding=utf-8

# toast提示必须安卓5.0以上


from appium import webdriver

from selenium.webdriver.support.ui import WebDriverWait

from selenium.webdriver.support import expected_conditions as EC


import time


def get_driver():


capabilities={

"platformName": "Android",

"automationName":"UiAutomator2",

"deviceName": "127.0.0.1:21503",

"app": "E:\\apptest\\appium_test\\apk\\imoc.apk",

# 注意这里的appActivity

"appWaitActivity":"com.imooc.component.imoocmain.splash.GuideActivity",

"noReset":"False"

}

driver=webdriver.Remote("http://127.0.0.1:4723/wd/hub",capabilities)

time.sleep(10)

return driver



def get_tost():

time.sleep(2)

# toast是不是需要时间等待

tost_element=("xpath","//*[contains(@text,'登录密码错误')]")

time.sleep(2)

print WebDriverWait(driver,10).until(EC.presence_of_element_located(tost_element))


driver = get_driver()




Traceback (most recent call last):

  File "E:\apptest\appium_test\testcase\case\toast_test.py", line 118, in <module>

    get_tost()

  File "E:\apptest\appium_test\testcase\case\toast_test.py", line 108, in get_tost

    print WebDriverWait(driver,10).until(EC.presence_of_element_located(tost_element))

  File "E:\cx\Python27\lib\site-packages\selenium-3.141.0-py2.7.egg\selenium\webdriver\support\wait.py", line 80, in until

    raise TimeoutException(message, screen, stacktrace)

selenium.common.exceptions.TimeoutException: Message: 


[Finished in 64.9s]


查看完整描述

目前暂无任何回答

添加回答

回复

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信