vigilant-kit 1.3.0__tar.gz → 1.4.0__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.

Potentially problematic release.


This version of vigilant-kit might be problematic. Click here for more details.

Files changed (31) hide show
  1. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/CHANGELOG.md +11 -0
  2. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/PKG-INFO +1 -9
  3. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/README.md +0 -7
  4. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/docs/configuration.md +4 -12
  5. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/pyproject.toml +2 -6
  6. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/src/vigilant/driver/__init__.py +1 -9
  7. vigilant_kit-1.4.0/src/vigilant/driver/vigilant_driver.py +45 -0
  8. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/vgl_config.yaml.example +1 -1
  9. vigilant_kit-1.3.0/src/vgl_cli/install_dev_kit_command.py +0 -14
  10. vigilant_kit-1.3.0/src/vgl_cli/install_standalone_command.py +0 -44
  11. vigilant_kit-1.3.0/src/vgl_cli/install_webdriver_command.py +0 -111
  12. vigilant_kit-1.3.0/src/vgl_cli/selenium_commands.py +0 -47
  13. vigilant_kit-1.3.0/src/vgl_cli/vgl.py +0 -26
  14. vigilant_kit-1.3.0/src/vigilant/driver/vigilant_driver.py +0 -87
  15. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/.gitignore +0 -0
  16. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/LICENSE +0 -0
  17. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/bin/doc_generator.py +0 -0
  18. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/docs/actions.md +0 -0
  19. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/docs/browser_options.md +0 -0
  20. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/docs/native_selenium.md +0 -0
  21. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/docs/selenium_install.md +0 -0
  22. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/docs/tutorial_pytest.md +0 -0
  23. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/docs/vigilant_pytest.md +0 -0
  24. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/docs/vigilant_unittest.md +0 -0
  25. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/src/vigilant/__init__.py +0 -0
  26. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/src/vigilant/actions/__init__.py +0 -0
  27. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/src/vigilant/actions/assertions.py +0 -0
  28. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/src/vigilant/actions/finder.py +0 -0
  29. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/src/vigilant/actions/vigilant_actions.py +0 -0
  30. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/src/vigilant/actions/waiter.py +0 -0
  31. {vigilant_kit-1.3.0 → vigilant_kit-1.4.0}/src/vigilant/logger.py +0 -0
@@ -1,4 +1,15 @@
1
1
  # Changelog for Vigilant Kit
2
+ ## Version 1.4.0
3
+
4
+ ### Code Refactoring
5
+ - Removed `vgl` CLI.
6
+ - Updated `VigilantDriver` class, now scripts can be run without Selenium server, only using local browser.
7
+ - Updated documentation related to new configuration.
8
+
9
+ ### Dependencies
10
+
11
+ - Removed pacakge: `click`.
12
+
2
13
 
3
14
  ## Version 1.3.0
4
15
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vigilant_kit
3
- Version: 1.3.0
3
+ Version: 1.4.0
4
4
  Summary: Library that makes functional testing with Selenium WebDriver fast and easy.
5
5
  Project-URL: Homepage, https://github.com/ivpel/vigilant
6
6
  Project-URL: Bug Tracker, https://github.com/ivpel/vigilant/issues
@@ -8,7 +8,6 @@ Author-email: Pelykh Ivan <ivan.pelykh@protonmail.com>
8
8
  License-File: LICENSE
9
9
  Keywords: bdd,functional,functional-testing,pytest,selenium,tdd,testing,unittest,webdriver
10
10
  Requires-Python: >=3.7
11
- Requires-Dist: click
12
11
  Requires-Dist: psutil
13
12
  Requires-Dist: python-dotenv
14
13
  Requires-Dist: pyyaml
@@ -60,11 +59,6 @@ conditions, and adaptive waiting mechanisms to accommodate different states and
60
59
  And much more! Check list of all available - [Actions](docs/actions.md)
61
60
 
62
61
 
63
- Also, CLI scripts included, to make your life easier!
64
-
65
- Use `vgl --help` to see all available commands.
66
-
67
-
68
62
  ## Extending Functionality
69
63
  If you need something that is not covered in this library, you still have access to all native `Selenium WebDriver`
70
64
  methods. You can create your own methods or use native `WebDriver` methods and share them on one browser session.
@@ -75,8 +69,6 @@ pip install vigilant-kit
75
69
  ```
76
70
 
77
71
  ## Docs
78
- ### Install
79
- - [How to install Selenium server & browser drivers](docs/selenium_install.md)
80
72
 
81
73
  ### Configuration
82
74
  - [Vigilant configuration](docs/configuration.md)
@@ -42,11 +42,6 @@ conditions, and adaptive waiting mechanisms to accommodate different states and
42
42
  And much more! Check list of all available - [Actions](docs/actions.md)
43
43
 
44
44
 
45
- Also, CLI scripts included, to make your life easier!
46
-
47
- Use `vgl --help` to see all available commands.
48
-
49
-
50
45
  ## Extending Functionality
51
46
  If you need something that is not covered in this library, you still have access to all native `Selenium WebDriver`
52
47
  methods. You can create your own methods or use native `WebDriver` methods and share them on one browser session.
@@ -57,8 +52,6 @@ pip install vigilant-kit
57
52
  ```
58
53
 
59
54
  ## Docs
60
- ### Install
61
- - [How to install Selenium server & browser drivers](docs/selenium_install.md)
62
55
 
63
56
  ### Configuration
64
57
  - [Vigilant configuration](docs/configuration.md)
@@ -16,9 +16,11 @@ Vigilant can be configured with the following options:
16
16
  **SELENIUM_HOST**
17
17
 
18
18
  - Description: The Selenium server host URL.
19
- - YAML Path: selenium-configuration.SELENIUM_HOST
19
+ - YAML Path: vgl-configuration.SELENIUM_HOST
20
20
  - Example: SELENIUM_HOST: http://127.0.0.1:4444/wd/hub
21
21
 
22
+ When use **SELENIUM_HOST**: local - local installed browser will be used.
23
+
22
24
  **SELENIUM_BROWSER**
23
25
 
24
26
  - Description: The browser to be used for testing.
@@ -42,25 +44,15 @@ Vigilant can be configured with the following options:
42
44
  The configuration file `vgl_config.yaml` should be structured as follows:
43
45
 
44
46
  ```yaml
45
- selenium-configuration:
47
+ vgl-configuration:
46
48
  BASE_URL: http://www.python.org
47
49
  SELENIUM_HOST: http://127.0.0.1:4444/wd/hub
48
50
  SELENIUM_BROWSER: firefox
49
51
  WAIT_TIMEOUT: 10
50
52
  LOGGER_LEVEL: INFO
51
- test-credentials:
52
- file: {credentials_file_name}.yaml
53
53
  ```
54
54
  You can modify the values in the YAML file to suit your specific configuration requirements.
55
55
 
56
- ## Test Credentials
57
- For secure storage of sensitive information like credentials, the YAML configuration file supports referencing an external file:
58
- ```yaml
59
- test-credentials:
60
- file: {credentials_file_name}.yaml
61
- ```
62
- Ensure that credentials.yaml is properly secured and not checked into version control.
63
-
64
56
  ## Environment Variables
65
57
  Vigilant will automatically load these settings as environment variables at runtime. There's no need to manually set
66
58
  environment variables if they are defined in the `vgl_config.yaml` file.
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "vigilant_kit"
7
- version = "1.3.0"
7
+ version = "1.4.0"
8
8
  authors = [
9
9
  { name="Pelykh Ivan", email="ivan.pelykh@protonmail.com" },
10
10
  ]
@@ -14,7 +14,6 @@ requires-python = ">=3.7"
14
14
  dependencies = [
15
15
  "selenium",
16
16
  "python-dotenv",
17
- "click",
18
17
  "requests",
19
18
  "psutil",
20
19
  "pyyaml"
@@ -23,7 +22,7 @@ dependencies = [
23
22
  keywords = ["testing", "selenium", "webdriver", "pytest", "unittest", "bdd", "tdd", "functional", "functional-testing"]
24
23
 
25
24
  [tool.hatch.build.targets.wheel]
26
- packages = ["src/vigilant", "src/vgl_cli"]
25
+ packages = ["src/vigilant"]
27
26
 
28
27
  classifiers = [
29
28
  "Programming Language :: Python :: 3",
@@ -34,6 +33,3 @@ classifiers = [
34
33
  [project.urls]
35
34
  "Homepage" = "https://github.com/ivpel/vigilant"
36
35
  "Bug Tracker" = "https://github.com/ivpel/vigilant/issues"
37
-
38
- [project.scripts]
39
- vgl = "vgl_cli.vgl:vgl"
@@ -10,17 +10,9 @@ def set_env_variables_from_yaml(yaml_path):
10
10
  with open(yaml_path, 'r') as file:
11
11
  configs = yaml.safe_load(file)
12
12
 
13
- selenium_config = configs.get('selenium-configuration', {})
13
+ selenium_config = configs.get('vgl-configuration', {})
14
14
  set_env_variables_from_dict(selenium_config)
15
15
 
16
- # Handle credentials
17
- creds_file_path = configs.get('test-credentials', {}).get('file')
18
- if creds_file_path and Path(creds_file_path).exists():
19
- with open(creds_file_path, 'r') as creds_file:
20
- credentials = yaml.safe_load(creds_file)
21
- set_env_variables_from_dict(credentials)
22
- else:
23
- print(f"Credentials file '{creds_file_path}' not found.")
24
16
 
25
17
  CONFIG_YAML_FILE = 'vgl_config.yaml'
26
18
 
@@ -0,0 +1,45 @@
1
+ import os
2
+
3
+ from selenium import webdriver
4
+
5
+ from vigilant.actions.vigilant_actions import VigilantActions
6
+ from vigilant.logger import logger as log
7
+
8
+
9
+ class VigilantDriver(VigilantActions):
10
+
11
+ SELENIUM_HOST = os.environ.get("SELENIUM_HOST")
12
+ SELENIUM_BROWSER = os.environ.get("SELENIUM_BROWSER")
13
+
14
+ def __init__(self):
15
+ browser_options = self.default_browser_options()
16
+ if self.SELENIUM_HOST in ["local", None, ""]:
17
+ self.driver = self.create_local_driver_session(browser_options)
18
+ else:
19
+ self.driver = self.create_remote_driver_session(browser_options)
20
+ VigilantActions.__init__(self, self.driver)
21
+
22
+ def default_browser_options(self):
23
+ options = None
24
+ if self.SELENIUM_BROWSER.lower() == "firefox":
25
+ options = webdriver.FirefoxOptions()
26
+ elif self.SELENIUM_BROWSER.lower() == "chrome":
27
+ options = webdriver.ChromeOptions()
28
+ log.info(f"Setting default browser options: {self.SELENIUM_BROWSER}")
29
+ return options
30
+
31
+ def create_remote_driver_session(self, browser_options):
32
+ log.info("Creating remote session.\n"
33
+ f"Command executor: {self.SELENIUM_HOST}\n"
34
+ f"Browser: {self.SELENIUM_BROWSER}")
35
+ return webdriver.Remote(command_executor=self.SELENIUM_HOST,
36
+ options=browser_options)
37
+
38
+ def create_local_driver_session(self, browser_options):
39
+ log.info("Creating local session.\n"
40
+ f"Browser: {self.SELENIUM_BROWSER}")
41
+ if self.SELENIUM_BROWSER.lower() == "firefox":
42
+ return webdriver.Firefox(options=browser_options)
43
+ elif self.SELENIUM_BROWSER.lower() == "chrome":
44
+ return webdriver.Chrome(options=browser_options)
45
+ raise ValueError("Unsupported browser specified")
@@ -1,6 +1,6 @@
1
1
  selenium-configuration:
2
2
  BASE_URL: http://www.python.org
3
- SELENIUM_HOST: http://127.0.0.1:4444/wd/hub
3
+ SELENIUM_HOST: local #http://127.0.0.1:4444/wd/hub
4
4
  SELENIUM_BROWSER: firefox
5
5
  WAIT_TIMEOUT: 10
6
6
  LOGGER_LEVEL: INFO
@@ -1,14 +0,0 @@
1
- import click
2
- from .install_webdriver_command import check_version_and_download_driver
3
- from .install_standalone_command import check_req_and_install_selenium_server
4
-
5
-
6
- @click.command(name='install:dev-kit', help="Install local development kit (Webdriver, Selenium Server, etc)")
7
- @click.option('-b', '--browser', type=click.Choice(['chrome', 'firefox', 'edge']), required=True)
8
- def install_dev_kit(browser):
9
- check_req_and_install_selenium_server()
10
- check_version_and_download_driver(browser)
11
-
12
-
13
- if __name__ == "__main__":
14
- install_dev_kit()
@@ -1,44 +0,0 @@
1
- import click
2
- import os
3
- import requests
4
-
5
- SELENIUM_SERVER_URL = "https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar"
6
- SELENIUM_SERVER_FILE = "selenium-server/selenium-server-standalone.jar"
7
-
8
-
9
- def check_selenium_requirements():
10
- java_path = os.popen("which java").read().strip()
11
- if not java_path:
12
- click.secho("Java is not installed on this machine.", fg="red")
13
- return False
14
-
15
- java_version = os.popen("java -version 2>&1 | awk -F '\"' '/version/ {print $2}'").read().strip()
16
- major_version = java_version.split('.')[0]
17
- if int(major_version) < 9:
18
- click.secho(f"Java version {java_version} is not supported. Please install Java 9 or higher.", fg="red")
19
- return False
20
-
21
- return True
22
-
23
-
24
- def download_selenium_server():
25
- response = requests.get(SELENIUM_SERVER_URL)
26
- os.makedirs("selenium-server", exist_ok=True)
27
- with open(SELENIUM_SERVER_FILE, "wb") as f:
28
- f.write(response.content)
29
-
30
-
31
- def check_req_and_install_selenium_server():
32
- if check_selenium_requirements():
33
- click.secho("Downloading Selenium Standalone server ...", nl=False)
34
- download_selenium_server()
35
- click.secho("OK", fg="green")
36
-
37
-
38
- @click.command(name="install:standalone", help="Install Selenium Standalone server.")
39
- def install_selenium_standalone():
40
- check_req_and_install_selenium_server()
41
-
42
-
43
- if __name__ == "__main__":
44
- install_selenium_standalone()
@@ -1,111 +0,0 @@
1
- import click
2
- import os
3
- import platform
4
- import requests
5
- import tarfile
6
- import zipfile
7
-
8
- BROWSER_VERSIONS = {
9
- "chrome": "https://chromedriver.storage.googleapis.com/LATEST_RELEASE",
10
- "firefox": "https://api.github.com/repos/mozilla/geckodriver/releases/latest",
11
- "edge": "https://msedgedriver.azureedge.net/LATEST_RELEASE"
12
- }
13
-
14
-
15
- def get_browser_version(browser):
16
- if browser == "chrome":
17
- # Get the latest version of Chrome from the output of the "google-chrome --version" command
18
- chrome_version = os.popen("google-chrome --version").read().strip().split()[-1]
19
- return chrome_version
20
- elif browser == "firefox":
21
- # Get the latest version of Firefox from the output of the "firefox --version" command
22
- firefox_version = os.popen("firefox --version").read().strip().split()[-1]
23
- return firefox_version.split('.')[0]
24
- elif browser == "edge":
25
- try:
26
- # Get the latest version of Edge from the output of the "msedge --version" command
27
- edge_version = os.popen("msedge --version").read().strip().split()[-1]
28
- return edge_version.split('.')[0]
29
- except IndexError:
30
- click.echo(f"Failed to get {browser} version")
31
- return None
32
- else:
33
- click.echo(f"{browser} is not a supported browser")
34
- return None
35
-
36
-
37
- def download_driver(browser, version):
38
- download_url = None
39
- if browser in BROWSER_VERSIONS:
40
- if browser == "chrome":
41
- # Get the major version of the Chrome browser installed on the machine
42
- chrome_version = get_browser_version(browser)
43
- if chrome_version is None:
44
- click.secho(f"{browser} is not installed on this machine.", fg="red")
45
- return
46
- # Use the ChromeDriver API to get the latest version of the ChromeDriver that is compatible with the installed Chrome browser
47
- response = requests.get(f"https://chromedriver.storage.googleapis.com/LATEST_RELEASE_{chrome_version.split('.')[0]}")
48
- if response.status_code == 200:
49
- latest_version = response.text
50
- download_url = f"https://chromedriver.storage.googleapis.com/{latest_version}/chromedriver_{platform.system().lower()}64.zip"
51
- else:
52
- click.secho(f"Could not find latest {browser} driver version.", fg="red")
53
- elif browser == "firefox":
54
- r = requests.get(BROWSER_VERSIONS[browser])
55
- release_info = r.json()
56
- for asset in release_info["assets"]:
57
- if platform.system().lower() in asset["name"] and "tar.gz" in asset["name"]:
58
- download_url = asset["browser_download_url"]
59
- break
60
- else:
61
- click.secho(f"Could not find latest {browser} driver version... Fail", fg="red")
62
- elif browser == "edge":
63
- download_url = f"https://msedgedriver.azureedge.net/{version}/edgedriver_{platform.system().lower()}.zip"
64
- else:
65
- click.secho(f"Invalid browser name '{browser}'", fg="red")
66
- return
67
- else:
68
- click.secho(f"Could not find browser '{browser}'.", fg="red")
69
- return
70
-
71
- if download_url is not None:
72
- response = requests.get(download_url)
73
- if download_url.endswith(".zip"):
74
- with open(f"selenium-server/{browser}_driver.zip", "wb") as f:
75
- f.write(response.content)
76
- with zipfile.ZipFile(f"selenium-server/{browser}_driver.zip", 'r') as zip_ref:
77
- for member in zip_ref.namelist():
78
- zip_ref.extract(member, f"selenium-server/")
79
- elif download_url.endswith(".tar.gz"):
80
- with open(f"selenium-server/{browser}_driver.tar.gz", "wb") as f:
81
- f.write(response.content)
82
- with tarfile.open(f"selenium-server/{browser}_driver.tar.gz", 'r:gz') as tar_ref:
83
- tar_ref.extractall(f"selenium-server/")
84
- else:
85
- click.secho(f"Could not find download URL for {browser} driver.", fg="red")
86
-
87
-
88
- def check_version_and_download_driver(browser):
89
- version = get_browser_version(browser)
90
- if version is None:
91
- click.secho(f"{browser} is not installed on this machine", fg="red")
92
- else:
93
- click.secho(f"Found: {browser} browser, version {version}.", fg="cyan")
94
- # Download the driver for the browser
95
- click.echo(f"Downloading driver for {browser} browser ... ", nl=False)
96
- download_driver(browser, version)
97
- click.secho("OK", fg="green")
98
-
99
-
100
- @click.command(name='install:webdriver', help="Install the webdriver for a chosen browser.")
101
- @click.option('-b', '--browser', type=click.Choice(['chrome', 'firefox', 'edge']), required=True)
102
- def install_webdriver(browser):
103
- # Create the selenium-server directory if it doesn't exist
104
- os.makedirs("selenium-server", exist_ok=True)
105
-
106
- # Check if the browser is installed and get its version
107
- check_version_and_download_driver(browser)
108
-
109
-
110
- if __name__ == "__main__":
111
- install_webdriver()
@@ -1,47 +0,0 @@
1
- import subprocess
2
- import click
3
- import psutil
4
-
5
- SELENIUM_SERVER_JAR = "selenium-server/selenium-server-standalone.jar"
6
-
7
-
8
- def find_selenium_server_process():
9
- for process in psutil.process_iter(['pid', 'name', 'cmdline']):
10
- if process.info['name'] == 'java' and SELENIUM_SERVER_JAR in process.info['cmdline']:
11
- return process
12
- return None
13
-
14
-
15
- @click.command(name='server:run', help="Run Selenium Server JAR file")
16
- @click.option('--port', '-p', type=int, default=4444, help="Port number for the server")
17
- @click.option('--driver', '-D', multiple=True,
18
- help="Specify driver options (e.g. -Dwebdriver.chrome.driver=chromedriver)")
19
- @click.option('--daemon', '-d', is_flag=True, help="Run the server as a daemon")
20
- def run_selenium_server(port, driver, daemon):
21
- driver_options = " ".join(driver)
22
- cmd = ["java", "-jar", SELENIUM_SERVER_JAR, "-port", str(port)]
23
- cmd.extend(driver_options.split())
24
-
25
- click.echo(f"Running Selenium Server with command:\n {' '.join(cmd)}")
26
-
27
- if daemon:
28
- # Start the process in the background (daemon mode) using subprocess.Popen
29
- process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
30
- click.echo(f"Selenium Server is running in daemon mode with PID: {process.pid}")
31
- else:
32
- # Start the process in the foreground and wait for it to finish using subprocess.run
33
- subprocess.run(cmd)
34
-
35
-
36
- @click.command(name='server:stop', help="Stop the running Selenium Server")
37
- def stop_selenium_server():
38
- selenium_server_process = find_selenium_server_process()
39
- if selenium_server_process:
40
- pid = selenium_server_process.info['pid']
41
- try:
42
- selenium_server_process.terminate()
43
- click.echo(f"Selenium Server with PID {pid} has been stopped.")
44
- except psutil.NoSuchProcess:
45
- click.echo(f"Failed to stop Selenium Server. Process with PID {pid} does not exist.")
46
- else:
47
- click.echo("Selenium Server is not running in daemon mode.")
@@ -1,26 +0,0 @@
1
- #!/usr/bin/env python
2
-
3
- import click
4
- from .install_webdriver_command import install_webdriver
5
- from .install_standalone_command import install_selenium_standalone
6
- from .install_dev_kit_command import install_dev_kit
7
-
8
- from .selenium_commands import run_selenium_server, stop_selenium_server
9
-
10
-
11
- @click.group(name="vgl.py")
12
- def vgl():
13
- pass
14
-
15
-
16
- vgl.add_command(run_selenium_server)
17
- vgl.add_command(stop_selenium_server)
18
-
19
-
20
- vgl.add_command(install_webdriver)
21
- vgl.add_command(install_selenium_standalone)
22
- vgl.add_command(install_dev_kit)
23
-
24
-
25
- if __name__ == '__main__':
26
- vgl()
@@ -1,87 +0,0 @@
1
- import os
2
-
3
- from selenium import webdriver
4
-
5
- from vigilant.actions.vigilant_actions import VigilantActions
6
- from vigilant.logger import logger as log
7
-
8
-
9
- class VigilantDriver(VigilantActions):
10
- """
11
- VigilantDriver class provide methods for running WebDriver instance from scratch using configuration
12
- from .vigilant.env file
13
-
14
- .vigilant.env configuration items:
15
- ----------------------------------
16
- SELENIUM_HOST - is used as command_executor, it is Selenium Server URI;
17
-
18
- SELENIUM_BROWSER - used as entity that show which browser options to use FirefoxOptions(),
19
- ChromeOptions, etc. (DesiredCapabilities is now deprecated, we should use Options() class).
20
-
21
- BASE_URL - the root URL of the application under test
22
-
23
- WAIT_TIMEOUT - configuration for the default amount of time (in seconds) that a
24
- test will wait while trying to interact with web element.
25
-
26
- LOGGER_LEVEL - level of verbosity that will be printed in to the console;
27
- """
28
-
29
- def __init__(self, browser_options=None):
30
- """
31
- `driver` - if you want access native Selenium WebDriver methods;
32
- VigilantActions - allow you to use custom methods for interaction with browser directly from VigilantDriver
33
- class instance;
34
-
35
- Examples:
36
- How to use VigilantActions methods;
37
-
38
- act = VigilantDriver()
39
- act.get_page('/')
40
- act.assertions.see_text('Some Text')
41
-
42
- How to access native Selenium WebDriver methods;
43
-
44
- act = VigilantDriver()
45
- act.driver.get('https://python.org') // Here we use Selenium WebDriver get() method
46
- """
47
- self.driver = self.create_remote_driver_session(browser_options)
48
- VigilantActions.__init__(self, self.driver)
49
-
50
- SELENIUM_HOST = os.environ.get("SELENIUM_HOST")
51
- SELENIUM_BROWSER = os.environ.get("SELENIUM_BROWSER")
52
-
53
- def default_browser_options(self):
54
- """
55
- Set browser options according to browser name provided in .vigilant.env file.
56
- It can be overwritten when user create new Selenium session by providing options as argument.
57
-
58
- Returns:
59
- Options: return default browser options according to value from SELENIUM_BROWSER variable.
60
- """
61
- options = None
62
- if self.SELENIUM_BROWSER.lower() == "firefox":
63
- options = webdriver.FirefoxOptions()
64
- elif self.SELENIUM_BROWSER.lower() == "chrome":
65
- options = webdriver.ChromeOptions()
66
- log.info(f"Setting default browser options: {self.SELENIUM_BROWSER}")
67
- return options
68
-
69
- def create_remote_driver_session(self, browser_options=None):
70
- """
71
- Create a new WebDriver instance that will issue commands using the wire protocol.
72
-
73
- Args:
74
- browser_options: browser options instance is required as it determines which browser will be used
75
-
76
- Returns:
77
- Remote: remote driver session based on configuration from .vigilant.env file
78
- """
79
- log.info("Creating remote session.\n"
80
- f"Command executor: {self.SELENIUM_HOST}\n"
81
- f"Browser: {self.SELENIUM_BROWSER}")
82
-
83
- if browser_options is None:
84
- browser_options = self.default_browser_options()
85
-
86
- return webdriver.Remote(command_executor=self.SELENIUM_HOST,
87
- options=browser_options)
File without changes
File without changes