2525def with_tag_name (tag_name : str ) -> "RelativeBy" :
2626 """Start searching for relative objects using a tag name.
2727
28- Parameters:
29- -----------
30- tag_name : str
31- The DOM tag of element to start searching.
28+ Args:
29+ tag_name: The DOM tag of element to start searching.
3230
3331 Returns:
34- --------
35- RelativeBy
36- Use this object to create filters within a `find_elements` call.
32+ RelativeBy: Use this object to create filters within a `find_elements` call.
3733
3834 Raises:
39- -------
40- WebDriverException
41- If `tag_name` is None.
42-
43- Notes:
44- ------
45- - This method is deprecated and may be removed in future versions.
46- - Please use `locate_with` instead.
35+ WebDriverException: If `tag_name` is None.
36+
37+ Note:
38+ This method is deprecated and may be removed in future versions.
39+ Please use `locate_with` instead.
4740 """
4841 warnings .warn ("This method is deprecated and may be removed in future versions. Please use `locate_with` instead." )
4942 if not tag_name :
@@ -54,23 +47,16 @@ def with_tag_name(tag_name: str) -> "RelativeBy":
5447def locate_with (by : ByType , using : str ) -> "RelativeBy" :
5548 """Start searching for relative objects your search criteria with By.
5649
57- Parameters:
58- -----------
59- by : ByType
60- The method to find the element.
61-
62- using : str
63- The value from `By` passed in.
50+ Args:
51+ by: The method to find the element.
52+ using: The value from `By` passed in.
6453
6554 Returns:
66- --------
67- RelativeBy
68- Use this object to create filters within a `find_elements` call.
55+ RelativeBy: Use this object to create filters within a `find_elements` call.
6956
7057 Example:
71- --------
72- >>> lowest = driver.find_element(By.ID, "below")
73- >>> elements = driver.find_elements(locate_with(By.CSS_SELECTOR, "p").above(lowest))
58+ >>> lowest = driver.find_element(By.ID, "below")
59+ >>> elements = driver.find_elements(locate_with(By.CSS_SELECTOR, "p").above(lowest))
7460 """
7561 assert by is not None , "Please pass in a by argument"
7662 assert using is not None , "Please pass in a using argument"
@@ -97,13 +83,9 @@ def __init__(self, root: Optional[dict[ByType, str]] = None, filters: Optional[l
9783 """Creates a new RelativeBy object. It is preferred if you use the
9884 `locate_with` method as this signature could change.
9985
100- Attributes:
101- -----------
102- root : Dict[By, str]
103- - A dict with `By` enum as the key and the search query as the value
104-
105- filters : List
106- - A list of the filters that will be searched. If none are passed
86+ Args:
87+ root: A dict with `By` enum as the key and the search query as the value
88+ filters: A list of the filters that will be searched. If none are passed
10789 in please use the fluent API on the object to create the filters
10890 """
10991 self .root = root
@@ -118,19 +100,14 @@ def above(self, element_or_locator: None = None) -> "NoReturn": ...
118100 def above (self , element_or_locator : Union [WebElement , LocatorType , None ] = None ) -> "RelativeBy" :
119101 """Add a filter to look for elements above.
120102
121- Parameters:
122- -----------
123- element_or_locator : Union[WebElement, Dict, None]
124- Element to look above
103+ Args:
104+ element_or_locator: Element to look above
125105
126106 Returns:
127- --------
128- RelativeBy
107+ RelativeBy
129108
130109 Raises:
131- -------
132- WebDriverException
133- If `element_or_locator` is None.
110+ WebDriverException: If `element_or_locator` is None.
134111
135112 Example:
136113 --------
@@ -152,24 +129,18 @@ def below(self, element_or_locator: None = None) -> "NoReturn": ...
152129 def below (self , element_or_locator : Union [WebElement , dict , None ] = None ) -> "RelativeBy" :
153130 """Add a filter to look for elements below.
154131
155- Parameters:
156- -----------
157- element_or_locator : Union[WebElement, Dict, None]
158- Element to look below
132+ Args:
133+ element_or_locator: Element to look below
159134
160135 Returns:
161- --------
162- RelativeBy
136+ RelativeBy
163137
164138 Raises:
165- -------
166- WebDriverException
167- If `element_or_locator` is None.
139+ WebDriverException: If `element_or_locator` is None.
168140
169141 Example:
170- --------
171- >>> highest = driver.find_element(By.ID, "high")
172- >>> elements = driver.find_elements(locate_with(By.CSS_SELECTOR, "p").below(highest))
142+ >>> highest = driver.find_element(By.ID, "high")
143+ >>> elements = driver.find_elements(locate_with(By.CSS_SELECTOR, "p").below(highest))
173144 """
174145 if not element_or_locator :
175146 raise WebDriverException ("Element or locator must be given when calling below method" )
@@ -186,24 +157,18 @@ def to_left_of(self, element_or_locator: None = None) -> "NoReturn": ...
186157 def to_left_of (self , element_or_locator : Union [WebElement , dict , None ] = None ) -> "RelativeBy" :
187158 """Add a filter to look for elements to the left of.
188159
189- Parameters:
190- -----------
191- element_or_locator : Union[WebElement, Dict, None]
192- Element to look to the left of
160+ Args:
161+ element_or_locator: Element to look to the left of
193162
194163 Returns:
195- --------
196- RelativeBy
164+ RelativeBy
197165
198166 Raises:
199- -------
200- WebDriverException
201- If `element_or_locator` is None.
167+ WebDriverException: If `element_or_locator` is None.
202168
203169 Example:
204- --------
205- >>> right = driver.find_element(By.ID, "right")
206- >>> elements = driver.find_elements(locate_with(By.CSS_SELECTOR, "p").to_left_of(right))
170+ >>> right = driver.find_element(By.ID, "right")
171+ >>> elements = driver.find_elements(locate_with(By.CSS_SELECTOR, "p").to_left_of(right))
207172 """
208173 if not element_or_locator :
209174 raise WebDriverException ("Element or locator must be given when calling to_left_of method" )
@@ -220,24 +185,18 @@ def to_right_of(self, element_or_locator: None = None) -> "NoReturn": ...
220185 def to_right_of (self , element_or_locator : Union [WebElement , dict , None ] = None ) -> "RelativeBy" :
221186 """Add a filter to look for elements right of.
222187
223- Parameters:
224- -----------
225- element_or_locator : Union[WebElement, Dict, None]
226- Element to look right of
188+ Args:
189+ element_or_locator: Element to look right of
227190
228191 Returns:
229- --------
230- RelativeBy
192+ RelativeBy
231193
232194 Raises:
233- -------
234- WebDriverException
235- If `element_or_locator` is None.
195+ WebDriverException: If `element_or_locator` is None.
236196
237197 Example:
238- --------
239- >>> left = driver.find_element(By.ID, "left")
240- >>> elements = driver.find_elements(locate_with(By.CSS_SELECTOR, "p").to_right_of(left))
198+ >>> left = driver.find_element(By.ID, "left")
199+ >>> elements = driver.find_elements(locate_with(By.CSS_SELECTOR, "p").to_right_of(left))
241200 """
242201 if not element_or_locator :
243202 raise WebDriverException ("Element or locator must be given when calling to_right_of method" )
@@ -254,8 +213,8 @@ def straight_above(self, element_or_locator: None = None) -> "NoReturn": ...
254213 def straight_above (self , element_or_locator : Union [WebElement , LocatorType , None ] = None ) -> "RelativeBy" :
255214 """Add a filter to look for elements above.
256215
257- : Args:
258- - element_or_locator: Element to look above
216+ Args:
217+ element_or_locator: Element to look above
259218 """
260219 if not element_or_locator :
261220 raise WebDriverException ("Element or locator must be given when calling above method" )
@@ -272,8 +231,8 @@ def straight_below(self, element_or_locator: None = None) -> "NoReturn": ...
272231 def straight_below (self , element_or_locator : Union [WebElement , dict , None ] = None ) -> "RelativeBy" :
273232 """Add a filter to look for elements below.
274233
275- : Args:
276- - element_or_locator: Element to look below
234+ Args:
235+ element_or_locator: Element to look below
277236 """
278237 if not element_or_locator :
279238 raise WebDriverException ("Element or locator must be given when calling below method" )
@@ -290,8 +249,8 @@ def straight_left_of(self, element_or_locator: None = None) -> "NoReturn": ...
290249 def straight_left_of (self , element_or_locator : Union [WebElement , dict , None ] = None ) -> "RelativeBy" :
291250 """Add a filter to look for elements to the left of.
292251
293- : Args:
294- - element_or_locator: Element to look to the left of
252+ Args:
253+ element_or_locator: Element to look to the left of
295254 """
296255 if not element_or_locator :
297256 raise WebDriverException ("Element or locator must be given when calling to_left_of method" )
@@ -308,8 +267,8 @@ def straight_right_of(self, element_or_locator: None = None) -> "NoReturn": ...
308267 def straight_right_of (self , element_or_locator : Union [WebElement , dict , None ] = None ) -> "RelativeBy" :
309268 """Add a filter to look for elements right of.
310269
311- : Args:
312- - element_or_locator: Element to look right of
270+ Args:
271+ element_or_locator: Element to look right of
313272 """
314273 if not element_or_locator :
315274 raise WebDriverException ("Element or locator must be given when calling to_right_of method" )
@@ -326,28 +285,20 @@ def near(self, element_or_locator: None = None, distance: int = 50) -> "NoReturn
326285 def near (self , element_or_locator : Union [WebElement , LocatorType , None ] = None , distance : int = 50 ) -> "RelativeBy" :
327286 """Add a filter to look for elements near.
328287
329- Parameters:
330- -----------
331- element_or_locator : Union[WebElement, Dict, None]
332- Element to look near by the element or within a distance
333-
334- distance : int
335- Distance in pixel
288+ Args:
289+ element_or_locator: Element to look near by the element or within a distance
290+ distance: Distance in pixel
336291
337292 Returns:
338- --------
339- RelativeBy
293+ RelativeBy
340294
341295 Raises:
342- -------
343- WebDriverException
344- - If `element_or_locator` is None
345- - If `distance` is less than or equal to 0.
296+ WebDriverException: If `element_or_locator` is None
297+ WebDriverException: If `distance` is less than or equal to 0.
346298
347299 Example:
348- --------
349- >>> near = driver.find_element(By.ID, "near")
350- >>> elements = driver.find_elements(locate_with(By.CSS_SELECTOR, "p").near(near, 50))
300+ >>> near = driver.find_element(By.ID, "near")
301+ >>> elements = driver.find_elements(locate_with(By.CSS_SELECTOR, "p").near(near, 50))
351302 """
352303 if not element_or_locator :
353304 raise WebDriverException ("Element or locator must be given when calling near method" )
0 commit comments