vigilant-kit 1.2.9__py3-none-any.whl → 1.4.0__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.
Potentially problematic release.
This version of vigilant-kit might be problematic. Click here for more details.
- vigilant/driver/__init__.py +16 -73
- vigilant/driver/vigilant_driver.py +18 -60
- {vigilant_kit-1.2.9.dist-info → vigilant_kit-1.4.0.dist-info}/METADATA +7 -14
- vigilant_kit-1.4.0.dist-info/RECORD +13 -0
- {vigilant_kit-1.2.9.dist-info → vigilant_kit-1.4.0.dist-info}/WHEEL +1 -1
- vgl_cli/install_dev_kit_command.py +0 -14
- vgl_cli/install_standalone_command.py +0 -44
- vgl_cli/install_webdriver_command.py +0 -111
- vgl_cli/selenium_commands.py +0 -47
- vgl_cli/vgl.py +0 -26
- vigilant_kit-1.2.9.dist-info/RECORD +0 -19
- vigilant_kit-1.2.9.dist-info/entry_points.txt +0 -2
- {vigilant_kit-1.2.9.dist-info → vigilant_kit-1.4.0.dist-info}/licenses/LICENSE +0 -0
vigilant/driver/__init__.py
CHANGED
|
@@ -1,81 +1,24 @@
|
|
|
1
1
|
import os
|
|
2
|
-
import
|
|
3
|
-
from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def check_env_variables_exist(variables):
|
|
7
|
-
missing_variables = []
|
|
8
|
-
for variable in variables:
|
|
9
|
-
if variable not in os.environ:
|
|
10
|
-
missing_variables.append(variable)
|
|
11
|
-
|
|
12
|
-
if missing_variables:
|
|
13
|
-
raise ValueError(f"Environment variables are missing: {', '.join(missing_variables)}")
|
|
14
|
-
|
|
15
|
-
return True
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def check_json_file_exist(filename):
|
|
19
|
-
current_dir = os.getcwd()
|
|
20
|
-
|
|
21
|
-
while True:
|
|
22
|
-
for root, dirs, files in os.walk(current_dir):
|
|
23
|
-
if filename in files:
|
|
24
|
-
return True
|
|
25
|
-
|
|
26
|
-
parent_dir = os.path.dirname(current_dir)
|
|
27
|
-
# Check if reached the root directory
|
|
28
|
-
if current_dir == parent_dir:
|
|
29
|
-
break
|
|
30
|
-
current_dir = parent_dir
|
|
31
|
-
|
|
32
|
-
return False
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def find_json_file(filename):
|
|
36
|
-
current_dir = os.getcwd()
|
|
37
|
-
|
|
38
|
-
while True:
|
|
39
|
-
for root, dirs, files in os.walk(current_dir):
|
|
40
|
-
if filename in files:
|
|
41
|
-
return os.path.join(root, filename)
|
|
42
|
-
|
|
43
|
-
parent_dir = os.path.dirname(current_dir)
|
|
44
|
-
# Check if reached the root directory
|
|
45
|
-
if current_dir == parent_dir:
|
|
46
|
-
break
|
|
47
|
-
current_dir = parent_dir
|
|
48
|
-
|
|
49
|
-
return None
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def set_env_variables_from_json(filename):
|
|
53
|
-
json_file_path = find_json_file(filename)
|
|
54
|
-
if json_file_path is None:
|
|
55
|
-
print(f"JSON file '{filename}' not found in the project's root directory or its subdirectories.")
|
|
56
|
-
return
|
|
57
|
-
|
|
58
|
-
with open(json_file_path, 'r') as file:
|
|
59
|
-
data = json.load(file)
|
|
2
|
+
import yaml
|
|
3
|
+
from pathlib import Path
|
|
60
4
|
|
|
5
|
+
def set_env_variables_from_dict(data):
|
|
61
6
|
for key, value in data.items():
|
|
62
7
|
os.environ[key] = str(value)
|
|
63
8
|
|
|
9
|
+
def set_env_variables_from_yaml(yaml_path):
|
|
10
|
+
with open(yaml_path, 'r') as file:
|
|
11
|
+
configs = yaml.safe_load(file)
|
|
12
|
+
|
|
13
|
+
selenium_config = configs.get('vgl-configuration', {})
|
|
14
|
+
set_env_variables_from_dict(selenium_config)
|
|
15
|
+
|
|
64
16
|
|
|
65
|
-
|
|
66
|
-
json_configuration_file = 'vigilant.json'
|
|
67
|
-
env_configuration_file = '.vigilant.env'
|
|
17
|
+
CONFIG_YAML_FILE = 'vgl_config.yaml'
|
|
68
18
|
|
|
69
|
-
if
|
|
70
|
-
print("Setting configuration from
|
|
71
|
-
|
|
72
|
-
elif check_json_file_exist(json_configuration_file):
|
|
73
|
-
print("Setting configuration from .vigilant.json file.")
|
|
74
|
-
set_env_variables_from_json(json_configuration_file)
|
|
19
|
+
if Path(CONFIG_YAML_FILE).exists():
|
|
20
|
+
print(f"Setting configuration from {CONFIG_YAML_FILE} file.")
|
|
21
|
+
set_env_variables_from_yaml(CONFIG_YAML_FILE)
|
|
75
22
|
else:
|
|
76
|
-
print("Could not find
|
|
77
|
-
print("If you don't want to use
|
|
78
|
-
"that you provide all configuration data as environment variables through the way that is acceptable for "
|
|
79
|
-
"you (pipeline configuration, custom bash script, etc.).")
|
|
80
|
-
if check_env_variables_exist(env_variables):
|
|
81
|
-
print("All mandatory environment variables exist.")
|
|
23
|
+
print(f"Could not find `{CONFIG_YAML_FILE}` configuration file.")
|
|
24
|
+
print("If you don't want to use the yaml configuration file, ensure you provide all configuration data as environment variables.")
|
|
@@ -7,57 +7,19 @@ from vigilant.logger import logger as log
|
|
|
7
7
|
|
|
8
8
|
|
|
9
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
10
|
|
|
50
11
|
SELENIUM_HOST = os.environ.get("SELENIUM_HOST")
|
|
51
12
|
SELENIUM_BROWSER = os.environ.get("SELENIUM_BROWSER")
|
|
52
13
|
|
|
53
|
-
def
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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)
|
|
57
21
|
|
|
58
|
-
|
|
59
|
-
Options: return default browser options according to value from SELENIUM_BROWSER variable.
|
|
60
|
-
"""
|
|
22
|
+
def default_browser_options(self):
|
|
61
23
|
options = None
|
|
62
24
|
if self.SELENIUM_BROWSER.lower() == "firefox":
|
|
63
25
|
options = webdriver.FirefoxOptions()
|
|
@@ -66,22 +28,18 @@ class VigilantDriver(VigilantActions):
|
|
|
66
28
|
log.info(f"Setting default browser options: {self.SELENIUM_BROWSER}")
|
|
67
29
|
return options
|
|
68
30
|
|
|
69
|
-
def create_remote_driver_session(self, browser_options
|
|
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
|
-
"""
|
|
31
|
+
def create_remote_driver_session(self, browser_options):
|
|
79
32
|
log.info("Creating remote session.\n"
|
|
80
33
|
f"Command executor: {self.SELENIUM_HOST}\n"
|
|
81
34
|
f"Browser: {self.SELENIUM_BROWSER}")
|
|
82
|
-
|
|
83
|
-
if browser_options is None:
|
|
84
|
-
browser_options = self.default_browser_options()
|
|
85
|
-
|
|
86
35
|
return webdriver.Remote(command_executor=self.SELENIUM_HOST,
|
|
87
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
|
Metadata-Version: 2.1
|
|
2
2
|
Name: vigilant_kit
|
|
3
|
-
Version: 1.
|
|
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,9 +8,9 @@ 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
|
|
13
|
+
Requires-Dist: pyyaml
|
|
14
14
|
Requires-Dist: requests
|
|
15
15
|
Requires-Dist: selenium
|
|
16
16
|
Description-Content-Type: text/markdown
|
|
@@ -22,17 +22,17 @@ Vigilant, you can start writing complex test cases in a minute.
|
|
|
22
22
|
## Why Vigilant?
|
|
23
23
|
* **Easy to start & Fast To Write**: Vigilant provides you with methods that help you write functional tests quickly
|
|
24
24
|
without spending time on writing boilerplate code every time you start a new project.
|
|
25
|
-
* **
|
|
26
|
-
pytest
|
|
27
|
-
* **Stability**: We use Selenium WebDriver. It is a W3C
|
|
25
|
+
* **No limit in usage**: You are not limited to a single testing framework; you can use Vigilant with **unittest**,
|
|
26
|
+
**pytest**, or for **scrapping data**. It's just a tool, use it as you want.
|
|
27
|
+
* **Stability**: We use Selenium WebDriver. It is a **W3C standard**.
|
|
28
28
|
- WebDriver drives a browser natively, as a user would, either locally or on a remote machine using the Selenium server.
|
|
29
29
|
- WebDriver is designed as a simple and more concise programming interface.
|
|
30
30
|
- WebDriver is a compact object-oriented API.
|
|
31
31
|
- It drives the browser effectively.
|
|
32
32
|
|
|
33
33
|
## What it includes?
|
|
34
|
-
Vigilant
|
|
35
|
-
|
|
34
|
+
Vigilant provide a suite of methods designed for efficient browser interaction, robust assertion of various
|
|
35
|
+
conditions, and adaptive waiting mechanisms to accommodate different states and conditions.
|
|
36
36
|
|
|
37
37
|
**Interacting with WebBrowser**
|
|
38
38
|
- `click()`
|
|
@@ -59,11 +59,6 @@ those conditions.
|
|
|
59
59
|
And much more! Check list of all available - [Actions](docs/actions.md)
|
|
60
60
|
|
|
61
61
|
|
|
62
|
-
Also, CLI scripts included, to make your life easier!
|
|
63
|
-
|
|
64
|
-
Use `vgl --help` to see all available commands.
|
|
65
|
-
|
|
66
|
-
|
|
67
62
|
## Extending Functionality
|
|
68
63
|
If you need something that is not covered in this library, you still have access to all native `Selenium WebDriver`
|
|
69
64
|
methods. You can create your own methods or use native `WebDriver` methods and share them on one browser session.
|
|
@@ -74,8 +69,6 @@ pip install vigilant-kit
|
|
|
74
69
|
```
|
|
75
70
|
|
|
76
71
|
## Docs
|
|
77
|
-
### Install
|
|
78
|
-
- [How to install Selenium server & browser drivers](docs/selenium_install.md)
|
|
79
72
|
|
|
80
73
|
### Configuration
|
|
81
74
|
- [Vigilant configuration](docs/configuration.md)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
vigilant/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
vigilant/logger.py,sha256=euYrqEDMEWNo9Eak31_4eTQEVzLZBwR8YiArhOtI9uQ,191
|
|
3
|
+
vigilant/actions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
vigilant/actions/assertions.py,sha256=OF81tGjl7qrjKuV7613owsmNHTXqa_pbpZVF7jZp6ms,6201
|
|
5
|
+
vigilant/actions/finder.py,sha256=Ibo1ltv2wzQ2Ol2pc_Lt2etKC08fjH3YSq1xhH0W8vg,2585
|
|
6
|
+
vigilant/actions/vigilant_actions.py,sha256=3XdXLIKN82aovLEWc6ed_LBy0CJgAzl6UDO3QzDkneU,13552
|
|
7
|
+
vigilant/actions/waiter.py,sha256=7S4BtffDR9jyue8lCw0_QsBfEERdXAVjkE-uepXffic,5064
|
|
8
|
+
vigilant/driver/__init__.py,sha256=NfSrz8wAYadeee2hzGty10eN6pa3CZxOD-6AZ6WqBlI,795
|
|
9
|
+
vigilant/driver/vigilant_driver.py,sha256=3iAdgcqut_q-IpBWIEuck8LhGbeMwCb8FSpmARZrXLA,1827
|
|
10
|
+
vigilant_kit-1.4.0.dist-info/METADATA,sha256=p3nlT8ShmkZKU3DIgIowTCHx_r_-IfqMbnbm29ECdZw,3118
|
|
11
|
+
vigilant_kit-1.4.0.dist-info/WHEEL,sha256=mRYSEL3Ih6g5a_CVMIcwiF__0Ae4_gLYh01YFNwiq1k,87
|
|
12
|
+
vigilant_kit-1.4.0.dist-info/licenses/LICENSE,sha256=VQoL58PKrdEeZx2K4hXS7O6w4O_DMBB0XFE-GjK1CMo,35125
|
|
13
|
+
vigilant_kit-1.4.0.dist-info/RECORD,,
|
|
@@ -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()
|
vgl_cli/selenium_commands.py
DELETED
|
@@ -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.")
|
vgl_cli/vgl.py
DELETED
|
@@ -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,19 +0,0 @@
|
|
|
1
|
-
vgl_cli/install_dev_kit_command.py,sha256=wVcUa0lHpu18zYMm0jO_ahuFEhmNwo9iVIKiMjH7j1Y,547
|
|
2
|
-
vgl_cli/install_standalone_command.py,sha256=3E3WX2nqdGHz343dJGkBbboDl-JFzZsa56lna7kLwsU,1447
|
|
3
|
-
vgl_cli/install_webdriver_command.py,sha256=xOljxceAVN1ZRkbyQNq55FbHXdKad2B4mNRBiS0fLHY,5032
|
|
4
|
-
vgl_cli/selenium_commands.py,sha256=z-FfRAn95q5JeJmATBp8yknMGP_WVoBt7gzSBmoKMLY,2029
|
|
5
|
-
vgl_cli/vgl.py,sha256=Ve-Z4d7zqzyGo88e7EpWEDYmRiOdxHsConmBMJ4F9YA,569
|
|
6
|
-
vigilant/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
vigilant/logger.py,sha256=euYrqEDMEWNo9Eak31_4eTQEVzLZBwR8YiArhOtI9uQ,191
|
|
8
|
-
vigilant/actions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
vigilant/actions/assertions.py,sha256=OF81tGjl7qrjKuV7613owsmNHTXqa_pbpZVF7jZp6ms,6201
|
|
10
|
-
vigilant/actions/finder.py,sha256=Ibo1ltv2wzQ2Ol2pc_Lt2etKC08fjH3YSq1xhH0W8vg,2585
|
|
11
|
-
vigilant/actions/vigilant_actions.py,sha256=3XdXLIKN82aovLEWc6ed_LBy0CJgAzl6UDO3QzDkneU,13552
|
|
12
|
-
vigilant/actions/waiter.py,sha256=7S4BtffDR9jyue8lCw0_QsBfEERdXAVjkE-uepXffic,5064
|
|
13
|
-
vigilant/driver/__init__.py,sha256=2NxWZ6OLLvGcrKRXvLtWPM1iGRE9zfIZtv_YUhNHj-I,2609
|
|
14
|
-
vigilant/driver/vigilant_driver.py,sha256=rw5CfWfBWOIFPgnkmxTi7cSbrrxLtDtRlxg2FMfyEVw,3398
|
|
15
|
-
vigilant_kit-1.2.9.dist-info/METADATA,sha256=70-QVoFw50-xBKoV4UoSln3b0Ku-0E7EWfY3p7lIfF4,3196
|
|
16
|
-
vigilant_kit-1.2.9.dist-info/WHEEL,sha256=9QBuHhg6FNW7lppboF2vKVbCGTVzsFykgRQjjlajrhA,87
|
|
17
|
-
vigilant_kit-1.2.9.dist-info/entry_points.txt,sha256=c_azSnuBSdtgwdPlioaG0n2gZOEhuPIzL9VQ8DeKTow,40
|
|
18
|
-
vigilant_kit-1.2.9.dist-info/licenses/LICENSE,sha256=VQoL58PKrdEeZx2K4hXS7O6w4O_DMBB0XFE-GjK1CMo,35125
|
|
19
|
-
vigilant_kit-1.2.9.dist-info/RECORD,,
|
|
File without changes
|