@@ -63,6 +63,55 @@ def __call__(self, driver):
63
63
return _find_element (driver , self .locator )
64
64
65
65
66
+ class url_contains (object ):
67
+ """ An expectation for checking that the current url contains a
68
+ case-sensitive substring.
69
+ url is the fragment of url expected,
70
+ returns True when the title matches, False otherwise
71
+ """
72
+ def __init__ (self , url ):
73
+ self .url = url
74
+
75
+ def __call__ (self , driver ):
76
+ return self .url in driver .current_url
77
+
78
+
79
+ class url_matches (object ):
80
+ """An expectation for checking the current url.
81
+ pattern is the expected pattern, which must be an exact match
82
+ returns True if the title matches, false otherwise."""
83
+ def __init__ (self , pattern ):
84
+ self .pattern = pattern
85
+
86
+ def __call__ (self , driver ):
87
+ import re
88
+ match = re .search (self .pattern , driver .current_url )
89
+
90
+ return match != None
91
+
92
+
93
+ class url_to_be (object ):
94
+ """An expectation for checking the current url.
95
+ url is the expected url, which must be an exact match
96
+ returns True if the title matches, false otherwise."""
97
+ def __init__ (self , url ):
98
+ self .url = url
99
+
100
+ def __call__ (self , driver ):
101
+ return self .url == driver .current_url
102
+
103
+
104
+ class url_changes (object ):
105
+ """An expectation for checking the current url.
106
+ url is the expected url, which must not be an exact match
107
+ returns True if the url is different, false otherwise."""
108
+ def __init__ (self , url ):
109
+ self .url = url
110
+
111
+ def __call__ (self , driver ):
112
+ return self .url != driver .current_url
113
+
114
+
66
115
class visibility_of_element_located (object ):
67
116
""" An expectation for checking that an element is present on the DOM of a
68
117
page and visible. Visibility means that the element is not only displayed
0 commit comments