1- from typing import Tuple , Union
2-
31from deprecated import deprecated
42from selenium .common .exceptions import NoSuchElementException
53from selenium .webdriver import ActionChains , Chrome , Edge , Firefox
64from selenium .webdriver .remote .webelement import WebElement
75from selenium .webdriver .support import expected_conditions
8- from selenium .webdriver .support .expected_conditions import (
9- StaleElementReferenceException ,
10- )
6+ from selenium .webdriver .support .expected_conditions import StaleElementReferenceException
117from selenium .webdriver .support .wait import WebDriverWait
128
139
1410class BasePage :
1511 """Wrapper for selenium operations."""
1612
17- def __init__ (self , driver : Union [ Chrome , Firefox , Edge ] , wait : WebDriverWait ):
13+ def __init__ (self , driver : Chrome | Firefox | Edge , wait : WebDriverWait ):
1814 self .driver = driver
1915 self .wait = wait
2016
@@ -39,42 +35,39 @@ def set_geo_location(self, latitude: float, longitude: float) -> None:
3935 """Sets the geolocation for the web browser using the Chrome DevTools
4036 Protocol (CDP).
4137
42- Parameters:
38+ Parameters
39+ ----------
4340 - latitude (float): The latitude of the desired geolocation.
4441 - longitude (float): The longitude of the desired geolocation.
4542
46- Returns:
43+ Returns
44+ -------
4745 None
4846
4947 Note:
5048 This method uses the Chrome DevTools Protocol (CDP) to override the geolocation
5149 in the web browser, allowing simulation of a specific geographic location for testing purposes.
5250 The accuracy is set to 1 for simplicity in this method.
51+
5352 """
5453 self .driver .execute_cdp_cmd (
5554 "Emulation.setGeolocationOverride" ,
5655 {"latitude" : latitude , "longitude" : longitude , "accuracy" : 1 },
5756 )
5857
59- def click (self , locator : Tuple [str , str ]) -> None :
60- el : WebElement = self .wait .until (
61- expected_conditions .element_to_be_clickable (locator )
62- )
58+ def click (self , locator : tuple [str , str ]) -> None :
59+ el : WebElement = self .wait .until (expected_conditions .element_to_be_clickable (locator ))
6360 self ._highlight_element (el , "green" )
6461 el .click ()
6562
66- def fill_text (self , locator : Tuple [str , str ], txt : str ) -> None :
67- el : WebElement = self .wait .until (
68- expected_conditions .element_to_be_clickable (locator )
69- )
63+ def fill_text (self , locator : tuple [str , str ], txt : str ) -> None :
64+ el : WebElement = self .wait .until (expected_conditions .element_to_be_clickable (locator ))
7065 el .clear ()
7166 self ._highlight_element (el , "green" )
7267 el .send_keys (txt )
7368
74- def clear_text (self , locator : Tuple [str , str ]) -> None :
75- el : WebElement = self .wait .until (
76- expected_conditions .element_to_be_clickable (locator )
77- )
69+ def clear_text (self , locator : tuple [str , str ]) -> None :
70+ el : WebElement = self .wait .until (expected_conditions .element_to_be_clickable (locator ))
7871 el .clear ()
7972
8073 def scroll_to_bottom (self ) -> None :
@@ -84,10 +77,8 @@ def submit(self, webelement: WebElement) -> None:
8477 self ._highlight_element (webelement , "green" )
8578 webelement .submit ()
8679
87- def get_text (self , locator : Tuple [str , str ]) -> str :
88- el : WebElement = self .wait .until (
89- expected_conditions .visibility_of_element_located (locator )
90- )
80+ def get_text (self , locator : tuple [str , str ]) -> str :
81+ el : WebElement = self .wait .until (expected_conditions .visibility_of_element_located (locator ))
9182 self ._highlight_element (el , "green" )
9283 return el .text
9384
0 commit comments