判断元素是否存在



clf = self.isElementPresent(driver,"xpath","//android.view.View[@resource-id='com.jifen.qukan:id/azx']")
if clf is True:
print(u"所查找的元素存在")
Ele = driver.find_element_by_xpath("//android.view.View[@resource-id='com.jifen.qukan:id/azx']")
TouchAction(driver).tap(Ele).perform().release()
else:
print(u"所查找的元素不存在")
try:
if driver.find_element_by_xpath("//android.widget.TextView[@text='多语言']").is_displayed(): # 判断是否有多语言录按钮,如果有result为False否则为Ture
result = True
except Exception:
result = False
self.assertEqual(result, True) # 断言


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM