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