File tree Expand file tree Collapse file tree 2 files changed +21
-7
lines changed Expand file tree Collapse file tree 2 files changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -62,9 +62,10 @@ def __call__(self, driver):
62
62
try :
63
63
elem = driver .find_element (By .CSS_SELECTOR , self .selector )
64
64
logger .debug ("contains text {%s} => expected %s" , elem .text , self .text )
65
- return self .text in str (elem .text ) or self .text in str (
66
- elem .get_attribute ("value" )
67
- )
65
+ if value := elem .get_attribute ("value" ) is not None :
66
+ return self .text in str (elem .text ) or self .text in str (value )
67
+ else :
68
+ return self .text in str (elem .text )
68
69
except WebDriverException :
69
70
return False
70
71
@@ -107,10 +108,10 @@ def __call__(self, driver):
107
108
try :
108
109
elem = self ._get_element (driver )
109
110
logger .debug ("text to equal {%s} => expected %s" , elem .text , self .text )
110
- return (
111
- str (elem .text ) == self .text
112
- or str ( elem . get_attribute ( "value" )) == self . text
113
- )
111
+ if value := elem . get_attribute ( "value" ) is not None :
112
+ return str (elem .text ) == self . text or str ( value ) == self .text
113
+ else :
114
+ return str ( elem . text ) == self . text
114
115
except WebDriverException :
115
116
return False
116
117
Original file line number Diff line number Diff line change @@ -14,6 +14,11 @@ def test_duo001_wait_for_text_error(dash_duo):
14
14
15
15
assert err .value .args [0 ] == "text -> Invalid not found within 1.0s, found: Content"
16
16
17
+ with pytest .raises (TimeoutException ) as err :
18
+ dash_duo .wait_for_text_to_equal ("#content" , "None" , timeout = 1.0 )
19
+
20
+ assert err .value .args [0 ] == "text -> None not found within 1.0s, found: Content"
21
+
17
22
with pytest .raises (TimeoutException ) as err :
18
23
dash_duo .wait_for_text_to_equal ("#none" , "None" , timeout = 1.0 )
19
24
@@ -27,6 +32,14 @@ def test_duo001_wait_for_text_error(dash_duo):
27
32
== "text -> invalid not found inside element within 1.0s, found: Content"
28
33
)
29
34
35
+ with pytest .raises (TimeoutException ) as err :
36
+ dash_duo .wait_for_contains_text ("#content" , "None" , timeout = 1.0 )
37
+
38
+ assert (
39
+ err .value .args [0 ]
40
+ == "text -> None not found inside element within 1.0s, found: Content"
41
+ )
42
+
30
43
with pytest .raises (TimeoutException ) as err :
31
44
dash_duo .wait_for_contains_text ("#none" , "none" , timeout = 1.0 )
32
45
You can’t perform that action at this time.
0 commit comments