@@ -2068,6 +2068,19 @@ def wait_for_text_visible(self, text, selector="html", by=By.CSS_SELECTOR,
2068
2068
return page_actions .wait_for_text_visible (
2069
2069
self .driver , text , selector , by , timeout )
2070
2070
2071
+ def wait_for_exact_text_visible (self , text , selector = "html" ,
2072
+ by = By .CSS_SELECTOR ,
2073
+ timeout = settings .LARGE_TIMEOUT ):
2074
+ if self .timeout_multiplier and timeout == settings .LARGE_TIMEOUT :
2075
+ timeout = self .__get_new_timeout (timeout )
2076
+ if page_utils .is_xpath_selector (selector ):
2077
+ by = By .XPATH
2078
+ if page_utils .is_link_text_selector (selector ):
2079
+ selector = page_utils .get_link_text_from_selector (selector )
2080
+ by = By .LINK_TEXT
2081
+ return page_actions .wait_for_exact_text_visible (
2082
+ self .driver , text , selector , by , timeout )
2083
+
2071
2084
def wait_for_text (self , text , selector = "html" , by = By .CSS_SELECTOR ,
2072
2085
timeout = settings .LARGE_TIMEOUT ):
2073
2086
""" The shorter version of wait_for_text_visible() """
@@ -2111,6 +2124,29 @@ def assert_text(self, text, selector="html", by=By.CSS_SELECTOR,
2111
2124
self .__highlight_with_assert_success (messenger_post , selector , by )
2112
2125
return True
2113
2126
2127
+ def assert_exact_text (self , text , selector = "html" , by = By .CSS_SELECTOR ,
2128
+ timeout = settings .SMALL_TIMEOUT ):
2129
+ """ Similar to assert_text(), but the text must be exact, rather than
2130
+ exist as a subset of the full text.
2131
+ (Extra whitespace at the beginning or the end doesn't count.)
2132
+ Raises an exception if the element or the text is not found.
2133
+ Returns True if successful. Default timeout = SMALL_TIMEOUT. """
2134
+ if self .timeout_multiplier and timeout == settings .SMALL_TIMEOUT :
2135
+ timeout = self .__get_new_timeout (timeout )
2136
+ self .wait_for_exact_text_visible (
2137
+ text , selector , by = by , timeout = timeout )
2138
+
2139
+ if self .demo_mode :
2140
+ if page_utils .is_xpath_selector (selector ):
2141
+ by = By .XPATH
2142
+ if page_utils .is_link_text_selector (selector ):
2143
+ selector = page_utils .get_link_text_from_selector (selector )
2144
+ by = By .LINK_TEXT
2145
+ messenger_post = ("ASSERT TEXT {%s} in %s: %s"
2146
+ % (text , by , selector ))
2147
+ self .__highlight_with_assert_success (messenger_post , selector , by )
2148
+ return True
2149
+
2114
2150
# For backwards compatibility, earlier method names of the next
2115
2151
# four methods have remained even though they do the same thing,
2116
2152
# with the exception of assert_*, which won't return the element,
0 commit comments