promethee-selenium 1.0.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.
@@ -0,0 +1,158 @@
1
+ Metadata-Version: 2.4
2
+ Name: promethee-selenium
3
+ Version: 1.0.0
4
+ Summary: Prométhée: A POM-based automated UI test framework
5
+ Author: Yann Dipita
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: selenium-ui-test-tool
8
+ Requires-Dist: pytest
9
+ Requires-Dist: selenium
10
+ Dynamic: author
11
+ Dynamic: description
12
+ Dynamic: description-content-type
13
+ Dynamic: requires-dist
14
+ Dynamic: summary
15
+
16
+ # Prométhée UI Framework
17
+
18
+ *[English version below | Version française plus bas]*
19
+
20
+ ---
21
+
22
+ # 🇬🇧 English Description
23
+
24
+ A robust, Page Object Model (POM) based framework for automated UI testing using Selenium and Pytest.
25
+
26
+ This framework is designed to help you write maintainable and scalable end-to-end tests with minimal boilerplate.
27
+
28
+ ## Features
29
+
30
+ - **Page Object Model (POM)**: Structured architecture separating page logic from test logic.
31
+ - **Scaffolding CLI**: Quickly initialize a new project with best-practice directory structure using `promethee init`.
32
+ - **Built-in Utilities**: Ready-to-use helpers for Waiting, Clicking, Filling inputs (via `selenium-ui-test-tool`).
33
+ - **Environment Management**: Easy handling of test data and credentials.
34
+ - **Documentation**: Includes HTML documentation to help you get started.
35
+
36
+ ## Installation
37
+
38
+ Install the package via pip:
39
+
40
+ ```bash
41
+ pip install promethee-selenium
42
+ ```
43
+
44
+ ## Getting Started
45
+
46
+ 1. **Create a new folder** for your test project:
47
+ ```bash
48
+ mkdir my_test_project
49
+ cd my_test_project
50
+ ```
51
+
52
+ 2. **Initialize the project structure**:
53
+ ```bash
54
+ promethee init
55
+ ```
56
+ To view the documentation in your browser:
57
+ ```bash
58
+ promethee docs
59
+ ```
60
+ This will create:
61
+ - `scenarios/`: For your Page Objects.
62
+ - `tests/`: For your test scripts.
63
+ - `data/`: For credentials and test data.
64
+ - `utils/`: For local utilities.
65
+ - `conftest.py`: Pytest configuration.
66
+
67
+ 3. **Run the sample test**:
68
+ ```bash
69
+ pytest tests/
70
+ ```
71
+
72
+ ## Writing a Page Object
73
+
74
+ Inherit from the `Base` class provided by the framework:
75
+
76
+ ```python
77
+ from promethee.base import Base
78
+ from selenium.webdriver.common.by import By
79
+ # Uses selenium-ui-test-tool functions internally
80
+
81
+ class LoginPage(Base):
82
+ def fill_form(self, username, password):
83
+ self.fill_input(By.ID, "username", username)
84
+ self.fill_input(By.ID, "password", password)
85
+ self.click_element(By.ID, "submit-btn")
86
+ ```
87
+
88
+ For more details, check the generated `docs/index.html` after installation.
89
+
90
+ ---
91
+
92
+ # 🇫🇷 Description Française
93
+
94
+ Un framework robuste basé sur le modèle Page Object Model (POM) pour l'automatisation de tests UI avec Selenium et Pytest.
95
+
96
+ Ce framework est conçu pour vous aider à écrire des tests de bout en bout maintenables et évolutifs avec un minimum de code répétitif.
97
+
98
+ ## Fonctionnalités
99
+
100
+ - **Page Object Model (POM)** : Architecture structurée séparant la logique de la page de la logique de test.
101
+ - **CLI d'initialisation** : Initialisez rapidement un nouveau projet avec une structure recommandée via `promethee init`.
102
+ - **Utilitaires intégrés** : Fonctions prêtes à l'emploi pour attendre, cliquer, remplir des champs (via `selenium-ui-test-tool`).
103
+ - **Gestion d'environnement** : Gestion facile des données de test et des identifiants.
104
+ - **Documentation** : Inclut une documentation HTML pour vous aider à démarrer.
105
+
106
+ ## Installation
107
+
108
+ Installez le paquet via pip :
109
+
110
+ ```bash
111
+ pip install Promethee-Selenium
112
+ ```
113
+
114
+ ## Démarrage Rapide
115
+
116
+ 1. **Créez un nouveau dossier** pour votre projet de test :
117
+ ```bash
118
+ mkdir mon_projet_test
119
+ cd mon_projet_test
120
+ ```
121
+
122
+ 2. **Initialisez la structure du projet** :
123
+ ```bash
124
+ promethee init
125
+ ```
126
+ Pour afficher la documentation dans votre navigateur :
127
+ ```bash
128
+ promethee docs
129
+ ```
130
+ Cela va créer :
131
+ - `scenarios/` : Pour vos Page Objects.
132
+ - `tests/` : Pour vos scripts de test.
133
+ - `data/` : Pour les identifiants et données de test.
134
+ - `utils/` : Pour les utilitaires locaux.
135
+ - `conftest.py` : Configuration Pytest.
136
+
137
+ 3. **Lancez le test d'exemple** :
138
+ ```bash
139
+ pytest tests/
140
+ ```
141
+
142
+ ## Écrire un Page Object
143
+
144
+ Héritez de la classe `Base` fournie par le framework :
145
+
146
+ ```python
147
+ from promethee.base import Base
148
+ from selenium.webdriver.common.by import By
149
+ # Utilise les fonctions selenium-ui-test-tool en interne
150
+
151
+ class LoginPage(Base):
152
+ def fill_form(self, username, password):
153
+ self.fill_input(By.ID, "username", username)
154
+ self.fill_input(By.ID, "password", password)
155
+ self.click_element(By.ID, "submit-btn")
156
+ ```
157
+
158
+ Pour plus de détails, consultez le fichier `docs/index.html` généré après l'installation.
@@ -0,0 +1,143 @@
1
+ # Prométhée UI Framework
2
+
3
+ *[English version below | Version française plus bas]*
4
+
5
+ ---
6
+
7
+ # 🇬🇧 English Description
8
+
9
+ A robust, Page Object Model (POM) based framework for automated UI testing using Selenium and Pytest.
10
+
11
+ This framework is designed to help you write maintainable and scalable end-to-end tests with minimal boilerplate.
12
+
13
+ ## Features
14
+
15
+ - **Page Object Model (POM)**: Structured architecture separating page logic from test logic.
16
+ - **Scaffolding CLI**: Quickly initialize a new project with best-practice directory structure using `promethee init`.
17
+ - **Built-in Utilities**: Ready-to-use helpers for Waiting, Clicking, Filling inputs (via `selenium-ui-test-tool`).
18
+ - **Environment Management**: Easy handling of test data and credentials.
19
+ - **Documentation**: Includes HTML documentation to help you get started.
20
+
21
+ ## Installation
22
+
23
+ Install the package via pip:
24
+
25
+ ```bash
26
+ pip install promethee-selenium
27
+ ```
28
+
29
+ ## Getting Started
30
+
31
+ 1. **Create a new folder** for your test project:
32
+ ```bash
33
+ mkdir my_test_project
34
+ cd my_test_project
35
+ ```
36
+
37
+ 2. **Initialize the project structure**:
38
+ ```bash
39
+ promethee init
40
+ ```
41
+ To view the documentation in your browser:
42
+ ```bash
43
+ promethee docs
44
+ ```
45
+ This will create:
46
+ - `scenarios/`: For your Page Objects.
47
+ - `tests/`: For your test scripts.
48
+ - `data/`: For credentials and test data.
49
+ - `utils/`: For local utilities.
50
+ - `conftest.py`: Pytest configuration.
51
+
52
+ 3. **Run the sample test**:
53
+ ```bash
54
+ pytest tests/
55
+ ```
56
+
57
+ ## Writing a Page Object
58
+
59
+ Inherit from the `Base` class provided by the framework:
60
+
61
+ ```python
62
+ from promethee.base import Base
63
+ from selenium.webdriver.common.by import By
64
+ # Uses selenium-ui-test-tool functions internally
65
+
66
+ class LoginPage(Base):
67
+ def fill_form(self, username, password):
68
+ self.fill_input(By.ID, "username", username)
69
+ self.fill_input(By.ID, "password", password)
70
+ self.click_element(By.ID, "submit-btn")
71
+ ```
72
+
73
+ For more details, check the generated `docs/index.html` after installation.
74
+
75
+ ---
76
+
77
+ # 🇫🇷 Description Française
78
+
79
+ Un framework robuste basé sur le modèle Page Object Model (POM) pour l'automatisation de tests UI avec Selenium et Pytest.
80
+
81
+ Ce framework est conçu pour vous aider à écrire des tests de bout en bout maintenables et évolutifs avec un minimum de code répétitif.
82
+
83
+ ## Fonctionnalités
84
+
85
+ - **Page Object Model (POM)** : Architecture structurée séparant la logique de la page de la logique de test.
86
+ - **CLI d'initialisation** : Initialisez rapidement un nouveau projet avec une structure recommandée via `promethee init`.
87
+ - **Utilitaires intégrés** : Fonctions prêtes à l'emploi pour attendre, cliquer, remplir des champs (via `selenium-ui-test-tool`).
88
+ - **Gestion d'environnement** : Gestion facile des données de test et des identifiants.
89
+ - **Documentation** : Inclut une documentation HTML pour vous aider à démarrer.
90
+
91
+ ## Installation
92
+
93
+ Installez le paquet via pip :
94
+
95
+ ```bash
96
+ pip install Promethee-Selenium
97
+ ```
98
+
99
+ ## Démarrage Rapide
100
+
101
+ 1. **Créez un nouveau dossier** pour votre projet de test :
102
+ ```bash
103
+ mkdir mon_projet_test
104
+ cd mon_projet_test
105
+ ```
106
+
107
+ 2. **Initialisez la structure du projet** :
108
+ ```bash
109
+ promethee init
110
+ ```
111
+ Pour afficher la documentation dans votre navigateur :
112
+ ```bash
113
+ promethee docs
114
+ ```
115
+ Cela va créer :
116
+ - `scenarios/` : Pour vos Page Objects.
117
+ - `tests/` : Pour vos scripts de test.
118
+ - `data/` : Pour les identifiants et données de test.
119
+ - `utils/` : Pour les utilitaires locaux.
120
+ - `conftest.py` : Configuration Pytest.
121
+
122
+ 3. **Lancez le test d'exemple** :
123
+ ```bash
124
+ pytest tests/
125
+ ```
126
+
127
+ ## Écrire un Page Object
128
+
129
+ Héritez de la classe `Base` fournie par le framework :
130
+
131
+ ```python
132
+ from promethee.base import Base
133
+ from selenium.webdriver.common.by import By
134
+ # Utilise les fonctions selenium-ui-test-tool en interne
135
+
136
+ class LoginPage(Base):
137
+ def fill_form(self, username, password):
138
+ self.fill_input(By.ID, "username", username)
139
+ self.fill_input(By.ID, "password", password)
140
+ self.click_element(By.ID, "submit-btn")
141
+ ```
142
+
143
+ Pour plus de détails, consultez le fichier `docs/index.html` généré après l'installation.
File without changes
File without changes
@@ -0,0 +1,27 @@
1
+ from selenium.webdriver.remote.webdriver import WebDriver
2
+
3
+ class Base:
4
+
5
+ def __init__(self, driver: WebDriver, url: str = None):
6
+ self.driver = driver
7
+ # Import local pour éviter l'import circulaire (car ConsentModal hérite de Base)
8
+ # On évite la récursion infinie : ConsentModal ne doit pas s'initialiser lui-même
9
+ if self.__class__.__name__ != 'ConsentModal':
10
+ try:
11
+ # from .utils.consent import ConsentModal
12
+ # self.consent_modal = ConsentModal(driver)
13
+ pass
14
+ except ImportError:
15
+ pass
16
+
17
+ if url:
18
+ self.open_url(url)
19
+
20
+ def open_url(self, url: str):
21
+ self.driver.get(url)
22
+
23
+ def get_title(self) -> str:
24
+ return self.driver.title
25
+
26
+ def refresh(self):
27
+ self.driver.refresh()
@@ -0,0 +1,165 @@
1
+ import argparse
2
+ import os
3
+ import shutil
4
+ import webbrowser
5
+ import sys
6
+
7
+ def open_docs():
8
+ """
9
+ Opens the framework documentation in the default web browser.
10
+ """
11
+ try:
12
+ # Try to locate the docs using pkg_resources (older but reliable) or file path relative to this file
13
+ # Since we are in promethee/cli.py, docs are in promethee/docs/index.html
14
+
15
+ # Method 1: Relative path from __file__
16
+ current_dir = os.path.dirname(os.path.abspath(__file__))
17
+ docs_path = os.path.join(current_dir, "docs", "index.html")
18
+
19
+ if os.path.exists(docs_path):
20
+ print(f"Opening documentation: {docs_path}")
21
+ webbrowser.open(f"file://{docs_path}")
22
+ else:
23
+ print("Documentation file not found locally.")
24
+ print("You can view it online on PyPI or GitHub.")
25
+
26
+ except Exception as e:
27
+ print(f"Failed to open documentation: {e}")
28
+
29
+ def init_project():
30
+ """
31
+ Initializes a new test project with the recommended structure.
32
+ """
33
+ base_dir = os.getcwd()
34
+ print(f"Initializing new test project in: {base_dir}")
35
+
36
+ # Define directories to create
37
+ dirs = ["scenarios", "tests", "data", "utils"]
38
+ for d in dirs:
39
+ path = os.path.join(base_dir, d)
40
+ if not os.path.exists(path):
41
+ os.makedirs(path)
42
+ print(f"Created directory: {d}")
43
+
44
+ # Create __init__.py in scenarios and utils to make them packages
45
+ for pkg in ["scenarios", "utils"]:
46
+ init_path = os.path.join(base_dir, pkg, "__init__.py")
47
+ if not os.path.exists(init_path):
48
+ with open(init_path, "w") as f:
49
+ pass
50
+
51
+ # Create utils/scenario_provider.py
52
+ scenario_provider_path = os.path.join(base_dir, "utils", "scenario_provider.py")
53
+ if not os.path.exists(scenario_provider_path):
54
+ with open(scenario_provider_path, "w") as f:
55
+ f.write("""import csv
56
+ import os
57
+
58
+ class ScenarioProvider:
59
+ # Look for credentials in the data directory
60
+ CREDENTIALS_FILE = os.path.join(os.getcwd(), 'data', 'credentials.csv')
61
+
62
+ @staticmethod
63
+ def get_data_for_scenario(scenario_name):
64
+ if not os.path.exists(ScenarioProvider.CREDENTIALS_FILE):
65
+ raise FileNotFoundError(f"Credentials file not found at {ScenarioProvider.CREDENTIALS_FILE}")
66
+
67
+ with open(ScenarioProvider.CREDENTIALS_FILE, mode='r', encoding='utf-8') as csvfile:
68
+ reader = csv.DictReader(csvfile)
69
+ for row in reader:
70
+ if row['scenario'] == scenario_name:
71
+ user_env_key = f"TEST_USER_{scenario_name.upper().replace(' ', '_')}"
72
+ pass_env_key = f"TEST_PASS_{scenario_name.upper().replace(' ', '_')}"
73
+ os.environ[user_env_key] = row['email']
74
+ os.environ[pass_env_key] = row['password']
75
+
76
+ return {
77
+ "username_env": user_env_key,
78
+ "password_env": pass_env_key
79
+ }
80
+
81
+ raise ValueError(f"Scenario '{scenario_name}' not found in credentials.csv")
82
+
83
+ @staticmethod
84
+ def prompt_for_scenario(default_scenario="login"):
85
+ # In automated environments (CI), you might want to switch this to read an env var
86
+ print(f"Using default scenario: {default_scenario}")
87
+ return default_scenario, ScenarioProvider.get_data_for_scenario(default_scenario)
88
+ """)
89
+ print("Created utils/scenario_provider.py")
90
+
91
+ # Create credentials.csv
92
+ creds_path = os.path.join(base_dir, "data", "credentials.csv")
93
+ if not os.path.exists(creds_path):
94
+ with open(creds_path, "w") as f:
95
+ f.write("scenario,email,password\\nlogin,test@example.com,secret123\\n")
96
+ print("Created data/credentials.csv")
97
+
98
+ # Create conftest.py
99
+ conftest_path = os.path.join(base_dir, "conftest.py")
100
+ if not os.path.exists(conftest_path):
101
+ with open(conftest_path, "w") as f:
102
+ f.write("""import pytest
103
+ from promethee.conftest import driver, base_url
104
+
105
+ # You can add local fixtures here
106
+ """)
107
+ print("Created conftest.py")
108
+
109
+ # Create sample scenario (login.py)
110
+ login_scenario_path = os.path.join(base_dir, "scenarios", "login.py")
111
+ if not os.path.exists(login_scenario_path):
112
+ with open(login_scenario_path, "w") as f:
113
+ f.write("""from promethee.base import Base
114
+ from selenium.webdriver.common.by import By
115
+ from selenium_ui_test_tool import fill_input, click_element, wait_for_element
116
+
117
+ class LoginPage(Base):
118
+ def fill_login_form(self, username, password):
119
+ print(f"Logging in with {username}...")
120
+ # Example implementation
121
+ # fill_input(self.driver, By.ID, "username", username)
122
+ # fill_input(self.driver, By.ID, "password", password)
123
+ # click_element(self.driver, By.ID, "login-btn")
124
+ """)
125
+ print("Created scenarios/login.py")
126
+
127
+ # Create generic sample test
128
+ test_path = os.path.join(base_dir, "tests", "test_login.py")
129
+ if not os.path.exists(test_path):
130
+ with open(test_path, "w") as f:
131
+ f.write("""from utils.scenario_provider import ScenarioProvider
132
+ from scenarios.login import LoginPage
133
+
134
+ def test_login(driver, base_url):
135
+ print("Running test_login...")
136
+ scenario_name, data = ScenarioProvider.prompt_for_scenario()
137
+
138
+ page = LoginPage(driver)
139
+ page.fill_login_form(data['username_env'], data['password_env'])
140
+
141
+ assert True
142
+ """)
143
+ print("Created tests/test_login.py")
144
+
145
+ print("\nProject initialized successfully!")
146
+ print("Run your tests with: pytest tests/")
147
+
148
+ def main():
149
+ parser = argparse.ArgumentParser(description="Prométhée UI Test Framework CLI")
150
+ subparsers = parser.add_subparsers(dest="command")
151
+
152
+ init_parser = subparsers.add_parser("init", help="Initialize a new test project")
153
+ docs_parser = subparsers.add_parser("docs", help="Open the documentation in browser")
154
+
155
+ args = parser.parse_args()
156
+
157
+ if args.command == "init":
158
+ init_project()
159
+ elif args.command == "docs":
160
+ open_docs()
161
+ else:
162
+ parser.print_help()
163
+
164
+ if __name__ == "__main__":
165
+ main()
@@ -0,0 +1,19 @@
1
+ import pytest
2
+ import os
3
+ from selenium_ui_test_tool import create_driver
4
+
5
+ @pytest.fixture(scope="function")
6
+ def driver():
7
+ """
8
+ Standard fixture to create a driver instance.
9
+ """
10
+ driver = create_driver()
11
+ yield driver
12
+ driver.quit()
13
+
14
+ @pytest.fixture(scope="session")
15
+ def base_url():
16
+ """
17
+ Returns the base URL. Can be overridden by environment variable or config.
18
+ """
19
+ return os.getenv("BASE_URL", "https://example.com")