判斷元素是否存在



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