wcp-library 1.4.7__py3-none-any.whl → 1.5.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
@@ -1,40 +1,20 @@
1
- from pathlib import Path
1
+ from abc import ABC
2
+ from dataclasses import field
2
3
  from typing import Optional
3
4
 
4
- from selenium import webdriver
5
5
  from selenium.webdriver.common.by import By
6
- from selenium.webdriver.chrome.service import Service
6
+ from selenium.webdriver.remote.webelement import WebElement
7
7
  from selenium.webdriver.support import expected_conditions
8
8
  from selenium.webdriver.support.wait import WebDriverWait
9
- from selenium.webdriver.remote.webelement import WebElement
10
- from webdriver_manager.chrome import ChromeDriverManager
11
9
 
12
10
 
13
- class SeleniumHelper:
14
- def __init__(self, headless: bool = False, download_path: Optional[Path] = None):
11
+ class SeleniumDriver(ABC):
12
+ def __init__(self, headless: bool = True, download_path: str = None):
15
13
  self._headless = headless
16
14
  self._download_path = download_path
15
+ self.driver = field(init=False)
17
16
 
18
- opt = webdriver.ChromeOptions()
19
- opt.add_argument("--start-maximized")
20
- if headless:
21
- opt.add_argument('headless')
22
-
23
- opt.page_load_strategy = 'eager'
24
-
25
- experimental_options_dict = {"download.prompt_for_download": False,
26
- "download.directory_upgrade": True,
27
- "safebrowsing.enabled": True}
28
- if download_path:
29
- experimental_options_dict["download.default_directory"] = str(download_path)
30
-
31
- opt.add_experimental_option("prefs", experimental_options_dict)
32
- opt.timeouts = {'implicit': 5000}
33
-
34
- self.driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=opt)
35
-
36
-
37
- def find_button_by_text(self, text: str) -> WebElement:
17
+ def find_button_by_text(self, text: str) -> WebElement | None:
38
18
  """
39
19
  Find a button by its text
40
20
 
@@ -52,7 +32,7 @@ class SeleniumHelper:
52
32
  if text in b.text:
53
33
  return b
54
34
 
55
- def find_span_by_text(self, text: str) -> WebElement:
35
+ def find_span_by_text(self, text: str) -> WebElement | None:
56
36
  """
57
37
  Find a span by its text
58
38
 
@@ -105,4 +85,4 @@ class SeleniumHelper:
105
85
  if css_element:
106
86
  WebDriverWait(self.driver, timeout).until(expected_conditions.element_to_be_clickable((By.CSS_SELECTOR, css_element)))
107
87
  elif link_text:
108
- WebDriverWait(self.driver, timeout).until(expected_conditions.element_to_be_clickable((By.LINK_TEXT, link_text)))
88
+ WebDriverWait(self.driver, timeout).until(expected_conditions.element_to_be_clickable((By.LINK_TEXT, link_text)))
@@ -0,0 +1,53 @@
1
+ from pathlib import Path
2
+ from typing import Optional
3
+
4
+ from get_gecko_driver import GetGeckoDriver
5
+ from selenium import webdriver
6
+ from selenium.webdriver.chrome.service import Service
7
+ from webdriver_manager.chrome import ChromeDriverManager
8
+
9
+ from wcp_library.selenium._selenium_driver import SeleniumDriver
10
+
11
+
12
+ class ChromeSeleniumHelper(SeleniumDriver):
13
+ def __init__(self, headless: bool = False, download_path: Optional[Path] = None):
14
+ super().__init__(headless, download_path)
15
+
16
+ opt = webdriver.ChromeOptions()
17
+ opt.add_argument("--start-maximized")
18
+ if headless:
19
+ opt.add_argument('headless')
20
+
21
+ opt.page_load_strategy = 'eager'
22
+
23
+ experimental_options_dict = {"download.prompt_for_download": False,
24
+ "download.directory_upgrade": True,
25
+ "safebrowsing.enabled": True}
26
+ if download_path:
27
+ experimental_options_dict["download.default_directory"] = str(download_path)
28
+
29
+ opt.add_experimental_option("prefs", experimental_options_dict)
30
+ opt.timeouts = {'implicit': 5000}
31
+
32
+ self.driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=opt)
33
+
34
+
35
+ class FirefoxSeleniumHelper(SeleniumDriver):
36
+ def __init__(self, headless: bool = False, download_path: Optional[Path] = None):
37
+ super().__init__(headless, download_path)
38
+
39
+ opt = webdriver.FirefoxOptions()
40
+ opt.add_argument("--start-maximized")
41
+ if headless:
42
+ opt.add_argument('--headless')
43
+
44
+ opt.page_load_strategy = 'eager'
45
+
46
+ if download_path:
47
+ opt.set_preference("browser.download.folderList", 2)
48
+ opt.set_preference("browser.download.dir", str(download_path))
49
+ opt.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream")
50
+
51
+ get_driver = GetGeckoDriver()
52
+ get_driver.install()
53
+ self.driver = webdriver.Firefox(options=opt)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: wcp-library
3
- Version: 1.4.7
3
+ Version: 1.5.2
4
4
  Summary: Common utilites for internal development at WCP
5
5
  Author: Mitch-Petersen
6
6
  Author-email: mitch.petersen@wcap.ca
@@ -10,6 +10,7 @@ Classifier: Programming Language :: Python :: 3.12
10
10
  Classifier: Programming Language :: Python :: 3.13
11
11
  Requires-Dist: aiohttp (>=3.10.10,<4.0.0)
12
12
  Requires-Dist: ftputil (>=5.1.0,<6.0.0)
13
+ Requires-Dist: get-gecko-driver (>=1.4,<2.0)
13
14
  Requires-Dist: oracledb (>=2.5.0,<3.0.0)
14
15
  Requires-Dist: pandas (>=2.2.3,<3.0.0)
15
16
  Requires-Dist: paramiko (>=3.5.0,<4.0.0)
@@ -20,7 +21,7 @@ Requires-Dist: psycopg-pool (>=3.2.3,<4.0.0)
20
21
  Requires-Dist: pycryptodome (>=3.21.0,<4.0.0)
21
22
  Requires-Dist: pytz (>=2024.2,<2025.0)
22
23
  Requires-Dist: requests (>=2.32.3,<3.0.0)
23
- Requires-Dist: selenium (>=4.27.1,<5.0.0)
24
+ Requires-Dist: selenium (>=4.31.0,<5.0.0)
24
25
  Requires-Dist: webdriver-manager (>=4.0.2,<5.0.0)
25
26
  Requires-Dist: yarl (>=1.17.1,<2.0.0)
26
27
  Project-URL: Documentation, https://github.com/Whitecap-DNA/WCP-Library/wiki
@@ -13,11 +13,13 @@ wcp_library/ftp/ftp.py,sha256=EpyW0J2QIGxP8zVGD4VarA0hi4C2XAPDPF-0j2sRdpI,4350
13
13
  wcp_library/ftp/sftp.py,sha256=hykXGLGdxe7DYAxFdTwjPjTEOYuIpSMyK3NOiTQNUK0,4176
14
14
  wcp_library/informatica.py,sha256=_g9lzSd-JLsY4e5_g6YcxQtOxP6fkg4sGfvNJaAN7jY,8123
15
15
  wcp_library/logging.py,sha256=e6gG7HFgUrMajUZs4Gs0atFfOJJmdmxN0GerfynNWlY,2061
16
- wcp_library/selenium_helper.py,sha256=w8YUC0pq7TkWiobc2ri4QR5fcHrrZgB5RAEfAdxZiuk,3780
16
+ wcp_library/selenium/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
+ wcp_library/selenium/_selenium_driver.py,sha256=Es83ISNryOVhYGDo_xrr8nCLsbnVBeXsaz1sRiz7kLI,2961
18
+ wcp_library/selenium/selenium_helper.py,sha256=OJvC0RlblfMWhmjNxiY582yuzkDgjzFZMuRz_8to3PY,2000
17
19
  wcp_library/sql/__init__.py,sha256=ocKH9-1HPDF5OhUKkpby3uNvQ6RBt2YD81nwwS90PgE,1980
18
20
  wcp_library/sql/oracle.py,sha256=jcGoH2iGkgxW-RJV5FRf_CwNzilkxPN6_pJ27te5Qe0,15815
19
21
  wcp_library/sql/postgres.py,sha256=Kfj5kfNwLyhE6bZIcqj6tjpbiGSyAMErY_Kr9eGm-2Q,14814
20
22
  wcp_library/time.py,sha256=ktSzhK7SZnGPNXobFexnhFGQAcriLCJQKxnO0fed8fQ,1740
21
- wcp_library-1.4.7.dist-info/METADATA,sha256=RGM4LGpK-JwoauS4O45Cgi8yBM2Vehz_thSD46YvONY,1497
22
- wcp_library-1.4.7.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
23
- wcp_library-1.4.7.dist-info/RECORD,,
23
+ wcp_library-1.5.2.dist-info/METADATA,sha256=WTa7ysh6BYW1KR4y5JBpcX_njy8lFOVcC4_uPkfSvpA,1542
24
+ wcp_library-1.5.2.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
25
+ wcp_library-1.5.2.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.1.1
2
+ Generator: poetry-core 2.1.2
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any