wcp-library 1.1.8__py3-none-any.whl → 1.1.9__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.
@@ -0,0 +1,77 @@
1
+ from pathlib import Path
2
+ from typing import Optional
3
+
4
+ from selenium import webdriver
5
+ from selenium.webdriver.common.by import By
6
+ from selenium.webdriver.chrome.service import Service
7
+ from selenium.webdriver.support import expected_conditions
8
+ from selenium.webdriver.support.wait import WebDriverWait
9
+ from selenium.webdriver.remote.webelement import WebElement
10
+ from webdriver_manager.chrome import ChromeDriverManager
11
+
12
+
13
+ class SeleniumHelper:
14
+ def __init__(self, headless: bool = False, download_path: Optional[Path] = None):
15
+ self._headless = headless
16
+ self._download_path = download_path
17
+
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:
38
+ """
39
+ Find a button by its text
40
+
41
+ :param text:
42
+ :return button element:
43
+ """
44
+
45
+ buttons = self.driver.find_elements(By.TAG_NAME, 'Button')
46
+ for b in buttons:
47
+ if b.text == text:
48
+ return b
49
+
50
+ # If there is something weird with the button text, this should find it
51
+ for b in buttons:
52
+ if text in b.text:
53
+ return b
54
+
55
+ def find_span_by_text(self, text: str) -> WebElement:
56
+ """
57
+ Find a span by its text
58
+
59
+ :param text:
60
+ :return span element:
61
+ """
62
+
63
+ buttons = self.driver.find_elements(By.TAG_NAME, 'Span')
64
+ for b in buttons:
65
+ if b.text == text:
66
+ return b
67
+
68
+ def wait_until_element_visible(self, css_element: str, timeout: int = 30) -> None:
69
+ """
70
+ Wait until an element is visible
71
+
72
+ :param css_element:
73
+ :param timeout:
74
+ :return:
75
+ """
76
+
77
+ WebDriverWait(self.driver, timeout).until(expected_conditions.presence_of_element_located((By.CSS_SELECTOR, css_element)))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wcp-library
3
- Version: 1.1.8
3
+ Version: 1.1.9
4
4
  Summary: Common utilites for internal development at WCP
5
5
  Home-page: https://github.com/Whitecap-DNA/WCP-Library
6
6
  Author: Mitch-Petersen
@@ -20,6 +20,8 @@ Requires-Dist: psycopg-binary (>=3.2.3,<4.0.0)
20
20
  Requires-Dist: psycopg-pool (>=3.2.3,<4.0.0)
21
21
  Requires-Dist: pycryptodome (>=3.21.0,<4.0.0)
22
22
  Requires-Dist: requests (>=2.32.3,<3.0.0)
23
+ Requires-Dist: selenium (>=4.27.1,<5.0.0)
24
+ Requires-Dist: webdriver-manager (>=4.0.2,<5.0.0)
23
25
  Requires-Dist: yarl (>=1.17.1,<2.0.0)
24
26
  Project-URL: Documentation, https://github.com/Whitecap-DNA/WCP-Library/wiki
25
27
  Project-URL: Repository, https://github.com/Whitecap-DNA/WCP-Library
@@ -16,9 +16,10 @@ wcp_library/ftp/ftp.py,sha256=EpyW0J2QIGxP8zVGD4VarA0hi4C2XAPDPF-0j2sRdpI,4350
16
16
  wcp_library/ftp/sftp.py,sha256=hykXGLGdxe7DYAxFdTwjPjTEOYuIpSMyK3NOiTQNUK0,4176
17
17
  wcp_library/informatica.py,sha256=IXZtk_9X1XLbOEwFrsyOwTgajQKvtXgANBHmuTOP3Kk,4064
18
18
  wcp_library/logging.py,sha256=tpnEuet-V6SK68JWk5cpt4K51YO0AxaebXrwGDGabFs,2048
19
+ wcp_library/selenium_helper.py,sha256=rlphTXsUgnbaXZknY5nfQqxFhnc7UmrpzhV3hQ-cv7k,2509
19
20
  wcp_library/sql/__init__.py,sha256=CLlBEBrWVAwE79bUxuQiwikSrYH8m9QRYSJ2l0-ofsY,1003
20
21
  wcp_library/sql/oracle.py,sha256=QT1-SHMs6ebQpzkJ1vjgsAP5TWHDdJF7pWL9QJ52O9Y,7235
21
22
  wcp_library/sql/postgres.py,sha256=I2iDQ13z_hbEfpFBliozLfsg8xUdSzEVqr12yyPSdh4,6489
22
- wcp_library-1.1.8.dist-info/METADATA,sha256=zBQOq7YYsEAB9lrbeqVSrokHvVwHri1-JO0NNJ8UhAE,1421
23
- wcp_library-1.1.8.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
24
- wcp_library-1.1.8.dist-info/RECORD,,
23
+ wcp_library-1.1.9.dist-info/METADATA,sha256=pT9xT59f-L2Adxx5ExaP9m8-r0J_vpHTPmpz82zbt5o,1513
24
+ wcp_library-1.1.9.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
25
+ wcp_library-1.1.9.dist-info/RECORD,,