Appium ways to get toast content

Source: Internet
Author: User

When you do automated testing, you may want to make the next decision based on the Toast prompt that pops up. Here's a record of how to get the toast content, while consolidating one of the ways to show the wait webdriverwait.

 fromSelenium.webdriver.supportImportexpected_conditions as ECdefFind_toast (self, driver, message, timeout=10, poll=0.01):    Try: Message='//*[@text =\ ' {}\ ']'. Format (Message)#Toast Contentelement =webdriverwait (Driver, Timeout,poll). Until (Ec.presence_of_element_located ((by.xpath, message) )        returnTrueexceptException as E:Print(("Get Toast Error:", E)) returnFalse

Presence_of_element_located can be replaced by

    • Title_is
    • Title_contains
    • presence_of_element_located
    • Visibility_of_element_located # and Presence_of_element_located's role is almost the same
    • 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

XPath in By.xpath can be replaced with ' class_name ', ' css_selector ', ' ID ', ' link_text ', ' NAME ', ' partial_link_text ', ' tag_name '

Appium ways to get toast content

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.