wcp-library 1.1.7__tar.gz → 1.1.9__tar.gz

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.
Files changed (25) hide show
  1. {wcp_library-1.1.7 → wcp_library-1.1.9}/PKG-INFO +3 -1
  2. {wcp_library-1.1.7 → wcp_library-1.1.9}/pyproject.toml +3 -1
  3. {wcp_library-1.1.7 → wcp_library-1.1.9}/wcp_library/__init__.py +1 -1
  4. wcp_library-1.1.9/wcp_library/selenium_helper.py +77 -0
  5. {wcp_library-1.1.7 → wcp_library-1.1.9}/README.md +0 -0
  6. {wcp_library-1.1.7 → wcp_library-1.1.9}/wcp_library/async_credentials/__init__.py +0 -0
  7. {wcp_library-1.1.7 → wcp_library-1.1.9}/wcp_library/async_credentials/api.py +0 -0
  8. {wcp_library-1.1.7 → wcp_library-1.1.9}/wcp_library/async_credentials/oracle.py +0 -0
  9. {wcp_library-1.1.7 → wcp_library-1.1.9}/wcp_library/async_credentials/postgres.py +0 -0
  10. {wcp_library-1.1.7 → wcp_library-1.1.9}/wcp_library/async_sql/__init__.py +0 -0
  11. {wcp_library-1.1.7 → wcp_library-1.1.9}/wcp_library/async_sql/oracle.py +0 -0
  12. {wcp_library-1.1.7 → wcp_library-1.1.9}/wcp_library/async_sql/postgres.py +0 -0
  13. {wcp_library-1.1.7 → wcp_library-1.1.9}/wcp_library/credentials/__init__.py +0 -0
  14. {wcp_library-1.1.7 → wcp_library-1.1.9}/wcp_library/credentials/ftp.py +0 -0
  15. {wcp_library-1.1.7 → wcp_library-1.1.9}/wcp_library/credentials/oracle.py +0 -0
  16. {wcp_library-1.1.7 → wcp_library-1.1.9}/wcp_library/credentials/postgres.py +0 -0
  17. {wcp_library-1.1.7 → wcp_library-1.1.9}/wcp_library/emailing.py +0 -0
  18. {wcp_library-1.1.7 → wcp_library-1.1.9}/wcp_library/ftp/__init__.py +0 -0
  19. {wcp_library-1.1.7 → wcp_library-1.1.9}/wcp_library/ftp/ftp.py +0 -0
  20. {wcp_library-1.1.7 → wcp_library-1.1.9}/wcp_library/ftp/sftp.py +0 -0
  21. {wcp_library-1.1.7 → wcp_library-1.1.9}/wcp_library/informatica.py +0 -0
  22. {wcp_library-1.1.7 → wcp_library-1.1.9}/wcp_library/logging.py +0 -0
  23. {wcp_library-1.1.7 → wcp_library-1.1.9}/wcp_library/sql/__init__.py +0 -0
  24. {wcp_library-1.1.7 → wcp_library-1.1.9}/wcp_library/sql/oracle.py +0 -0
  25. {wcp_library-1.1.7 → wcp_library-1.1.9}/wcp_library/sql/postgres.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wcp-library
3
- Version: 1.1.7
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
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "wcp-library"
3
- version = "1.1.7"
3
+ version = "1.1.9"
4
4
  description = "Common utilites for internal development at WCP"
5
5
  authors = ["Mitch-Petersen <mitch.petersen@wcap.ca>"]
6
6
  readme = "README.md"
@@ -21,6 +21,8 @@ psycopg-binary = "^3.2.3"
21
21
  psycopg-pool = "^3.2.3"
22
22
  pycryptodome = "^3.21.0"
23
23
  requests = "^2.32.3"
24
+ selenium = "^4.27.1"
25
+ webdriver-manager = "^4.0.2"
24
26
  yarl = "^1.17.1"
25
27
 
26
28
  [build-system]
@@ -12,4 +12,4 @@ if getattr(sys, 'frozen', False):
12
12
  application_path = sys.executable
13
13
  application_path = Path(application_path).parent
14
14
  else:
15
- application_path = Path(os.environ['VIRTUAL_ENV']).parent
15
+ application_path = Path().absolute()
@@ -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)))
File without changes