Skip to content

Commit 6ddaaf3

Browse files
authored
[py] make relative_locator errors meaningful (#11284)
[skip ci]
1 parent 0231def commit 6ddaaf3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

py/selenium/webdriver/support/relative_locator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def below(self, element_or_locator: Union[WebElement, Dict] = None) -> "Relative
105105
- element_or_locator: Element to look below
106106
"""
107107
if not element_or_locator:
108-
raise WebDriverException("Element or locator must be given when calling above method")
108+
raise WebDriverException("Element or locator must be given when calling below method")
109109

110110
self.filters.append({"kind": "below", "args": [element_or_locator]})
111111
return self
@@ -117,7 +117,7 @@ def to_left_of(self, element_or_locator: Union[WebElement, Dict] = None) -> "Rel
117117
- element_or_locator: Element to look to the left of
118118
"""
119119
if not element_or_locator:
120-
raise WebDriverException("Element or locator must be given when calling above method")
120+
raise WebDriverException("Element or locator must be given when calling to_left_of method")
121121

122122
self.filters.append({"kind": "left", "args": [element_or_locator]})
123123
return self
@@ -129,7 +129,7 @@ def to_right_of(self, element_or_locator: Union[WebElement, Dict] = None) -> "Re
129129
- element_or_locator: Element to look right of
130130
"""
131131
if not element_or_locator:
132-
raise WebDriverException("Element or locator must be given when calling above method")
132+
raise WebDriverException("Element or locator must be given when calling to_right_of method")
133133

134134
self.filters.append({"kind": "right", "args": [element_or_locator]})
135135
return self
@@ -141,7 +141,7 @@ def near(self, element_or_locator_distance: Union[WebElement, Dict, int] = None)
141141
- element_or_locator_distance: Element to look near by the element or within a distance
142142
"""
143143
if not element_or_locator_distance:
144-
raise WebDriverException("Element or locator or distance must be given when calling above method")
144+
raise WebDriverException("Element or locator or distance must be given when calling near method")
145145

146146
self.filters.append({"kind": "near", "args": [element_or_locator_distance]})
147147
return self

0 commit comments

Comments
 (0)