From 492f6346849fb9bc5cdca5fb9cd88ae24c296fd7 Mon Sep 17 00:00:00 2001 From: Victor Emanouilov Date: Wed, 1 May 2024 00:06:19 +0300 Subject: [PATCH] fix selenium tests to use a helper php file to get the current cypht configuration --- tests/selenium/base.py | 12 ++++-------- tests/selenium/get_config.php | 7 +++++++ 2 files changed, 11 insertions(+), 8 deletions(-) create mode 100644 tests/selenium/get_config.php diff --git a/tests/selenium/base.py b/tests/selenium/base.py index 9b47a84b4d..06abe5c440 100644 --- a/tests/selenium/base.py +++ b/tests/selenium/base.py @@ -15,6 +15,8 @@ from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as exp_cond import glob +import subprocess +import json class WebTest: @@ -31,18 +33,12 @@ def __init__(self, cap=None): def read_ini(self): self.modules = [] self.auth_type = '' - # Assuming each PHP file returns an associative array config_files = glob.glob('../../config/*.php') - for file_path in config_files: - # Create an empty dictionary to hold the variables from the included file - config_dict = {} - # Execute the PHP file in a new dictionary - exec(open(file_path).read(), config_dict) - # Check if 'modules' is in the dictionary and is a list + result = subprocess.run(['php', 'get_config.php'], stdout=subprocess.PIPE) + config_dict = json.loads(result.stdout.decode()) if 'modules' in config_dict and isinstance(config_dict['modules'], list): self.modules += config_dict['modules'] - # Check if 'auth_type' is in the dictionary if 'auth_type' in config_dict: self.auth_type = config_dict['auth_type'] diff --git a/tests/selenium/get_config.php b/tests/selenium/get_config.php new file mode 100644 index 0000000000..64c1a06ab6 --- /dev/null +++ b/tests/selenium/get_config.php @@ -0,0 +1,7 @@ +