@@ -60,7 +60,7 @@ def locate_with(by: ByType, using: str) -> "RelativeBy":
6060
6161class RelativeBy :
6262 """Gives the opportunity to find elements based on their relative location
63- on the page from a root elelemt . It is recommended that you use the helper
63+ on the page from a root element . It is recommended that you use the helper
6464 function to create it.
6565
6666 Example:
@@ -159,6 +159,78 @@ def to_right_of(self, element_or_locator: Union[WebElement, Dict, None] = None)
159159 self .filters .append ({"kind" : "right" , "args" : [element_or_locator ]})
160160 return self
161161
162+ @overload
163+ def straight_above (self , element_or_locator : Union [WebElement , LocatorType ]) -> "RelativeBy" : ...
164+
165+ @overload
166+ def straight_above (self , element_or_locator : None = None ) -> "NoReturn" : ...
167+
168+ def straight_above (self , element_or_locator : Union [WebElement , LocatorType , None ] = None ) -> "RelativeBy" :
169+ """Add a filter to look for elements above.
170+
171+ :Args:
172+ - element_or_locator: Element to look above
173+ """
174+ if not element_or_locator :
175+ raise WebDriverException ("Element or locator must be given when calling above method" )
176+
177+ self .filters .append ({"kind" : "straightAbove" , "args" : [element_or_locator ]})
178+ return self
179+
180+ @overload
181+ def straight_below (self , element_or_locator : Union [WebElement , LocatorType ]) -> "RelativeBy" : ...
182+
183+ @overload
184+ def straight_below (self , element_or_locator : None = None ) -> "NoReturn" : ...
185+
186+ def straight_below (self , element_or_locator : Union [WebElement , Dict , None ] = None ) -> "RelativeBy" :
187+ """Add a filter to look for elements below.
188+
189+ :Args:
190+ - element_or_locator: Element to look below
191+ """
192+ if not element_or_locator :
193+ raise WebDriverException ("Element or locator must be given when calling below method" )
194+
195+ self .filters .append ({"kind" : "straightBelow" , "args" : [element_or_locator ]})
196+ return self
197+
198+ @overload
199+ def straight_left_of (self , element_or_locator : Union [WebElement , LocatorType ]) -> "RelativeBy" : ...
200+
201+ @overload
202+ def straight_left_of (self , element_or_locator : None = None ) -> "NoReturn" : ...
203+
204+ def straight_left_of (self , element_or_locator : Union [WebElement , Dict , None ] = None ) -> "RelativeBy" :
205+ """Add a filter to look for elements to the left of.
206+
207+ :Args:
208+ - element_or_locator: Element to look to the left of
209+ """
210+ if not element_or_locator :
211+ raise WebDriverException ("Element or locator must be given when calling to_left_of method" )
212+
213+ self .filters .append ({"kind" : "straightLeft" , "args" : [element_or_locator ]})
214+ return self
215+
216+ @overload
217+ def straight_right_of (self , element_or_locator : Union [WebElement , LocatorType ]) -> "RelativeBy" : ...
218+
219+ @overload
220+ def straight_right_of (self , element_or_locator : None = None ) -> "NoReturn" : ...
221+
222+ def straight_right_of (self , element_or_locator : Union [WebElement , Dict , None ] = None ) -> "RelativeBy" :
223+ """Add a filter to look for elements right of.
224+
225+ :Args:
226+ - element_or_locator: Element to look right of
227+ """
228+ if not element_or_locator :
229+ raise WebDriverException ("Element or locator must be given when calling to_right_of method" )
230+
231+ self .filters .append ({"kind" : "straightRight" , "args" : [element_or_locator ]})
232+ return self
233+
162234 @overload
163235 def near (self , element_or_locator : Union [WebElement , LocatorType ], distance : int = 50 ) -> "RelativeBy" : ...
164236
0 commit comments