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