appium擷取Toast內容的方法

來源:互聯網
上載者:User

標籤:support   測試的   sele   expect   需要   appium   poll   顯示   err   

做自動化測試的時候,可能需要根據彈出的Toast提示來做下一步判斷。這裡記錄一下擷取Toast內容的方法,同時鞏固一下顯示等待的方法之一WebDriverWait。

from selenium.webdriver.support import expected_conditions as ecdef find_toast(self, driver, message, timeout=10, poll=0.01):    try:        message = ‘//*[@text=\‘{}\‘]‘.format(message) #Toast內容        element = WebDriverWait(driver, timeout,poll).until(ec.presence_of_element_located((By.XPATH, message)))        return True    except Exception as e:        print(("Get Toast Error : ", e))        return False

presence_of_element_located可以替換為

  • title_is
  • title_contains
  • presence_of_element_located
  • visibility_of_element_located   # 和 presence_of_element_located 的作用幾乎一樣
  • visibility_of
  • presence_of_all_elements_located
  • text_to_be_present_in_element
  • text_to_be_present_in_element_value
  • frame_to_be_available_and_switch_to_it
  • invisibility_of_element_located
  • element_to_be_clickable - it is Displayed and Enabled.
  • staleness_of
  • element_to_be_selected
  • element_located_to_be_selected
  • element_selection_state_to_be
  • element_located_selection_state_to_be
  • alert_is_present

By.XPATH中的XPATH可替換為‘CLASS_NAME‘, ‘CSS_SELECTOR‘, ‘ID‘, ‘LINK_TEXT‘, ‘NAME‘, ‘PARTIAL_LINK_TEXT‘, ‘TAG_NAME‘

 

appium擷取Toast內容的方法

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.