You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+25-25Lines changed: 25 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
Selpy-Python is a Page Object Model (POM) framework for selenium automation with python `pytest`. This framework uses 'pytest-xdist' module to run multiple threads to run the tests at the same time depending on the number of available processor cores (2X of number of available cores).
4
4
5
-
This framework also uses [selpy](https://pypi.org/project/selpy/) custom built pypi module to implement snapshot feature (which is available in jest framework). If there are any change in UI we can directly change this in the test data file during the test run with ease. Manual maintenance of test data can be reduced drastically with this feature.
5
+
This framework also uses _**[selpy](https://pypi.org/project/selpy/) custom built pypi module**_ to implement snapshot feature (which is available in jest framework). If there are any change in UI we can directly change this in the test data file during the test run with ease. Manual maintenance of test data can be reduced drastically with this feature.
6
6
7
7
More details of this module can be refered in [selpy](https://pypi.org/project/selpy/) or [repo](https://github.com/nareshnavinash/selpy)
8
8
@@ -42,31 +42,31 @@ More details of this module can be refered in [selpy](https://pypi.org/project/s
42
42
## To Run the tests
43
43
For a simple run of all the test files in normal mode, try
44
44
45
-
```shell script
45
+
```
46
46
pytest
47
47
```
48
48
49
49
To run the tests in snap mode (to save the UI texts to the dynamic file)
50
-
```shell script
50
+
```
51
51
snap=1 pytest
52
52
```
53
53
Once the changes are saved to the file run the tests with `pytest` to get the test running against the saved data. To verify this feature I intentionally added two locator texts which will be changing continuously.
54
54
55
55
To Run the tests in parallel mode or multi thread run for the available test files, try (To have parallel run you need to have atleast 2 tests inside your folder structure)
56
56
57
-
```shell script
57
+
```
58
58
pytest -s -v -n=2
59
59
```
60
60
61
61
To Run the tests in parallel mode for the available test files along with browser specification, try
62
62
63
-
```shell script
63
+
```
64
64
browser=chrome pytest -s -v -n=2
65
65
```
66
66
67
67
To Run the tests in parallel mode for the available test files in headless mode, try
68
68
69
-
```shell script
69
+
```
70
70
headless=1 browser=chrome pytest -s -v -n=2
71
71
```
72
72
@@ -75,14 +75,14 @@ This will run the tests in headless mode
75
75
## To open allure results
76
76
Allure is a open source framework for reporting the test runs. To install allure in mac, use the following steps
77
77
78
-
```shell script
78
+
```
79
79
brew cask install adoptopenjdk
80
80
brew install allure
81
81
```
82
82
83
83
To view the results for the test run, use
84
84
85
-
```shell script
85
+
```
86
86
allure serve reports/allure
87
87
```
88
88
@@ -98,7 +98,7 @@ For better illustration on the testcases, allure reports has been integrated. Al
98
98
## Jenkins Integration with Docker images
99
99
Get any of the linux with python docker image as the slaves in jenkins and use the same for executing the UI automation with this framework (Sample docker image - `https://hub.docker.com/_/python`). From the jenkins bash Execute the following to get the testcases to run,
100
100
101
-
```shell script
101
+
```
102
102
#!/usr/bin/python3
103
103
python --version
104
104
cd <path_to_the_project>
@@ -108,7 +108,7 @@ headless=1 pytest -s -v -n 4
108
108
109
109
In Jenkins pipeline, try to add the following snippet to execute the tests,
110
110
111
-
```shell script
111
+
```
112
112
pipeline {
113
113
agent { docker { image 'python:3.7.6' } }
114
114
stages {
@@ -137,7 +137,7 @@ In `Data/GlobalData/global_data.yml` file, if the headless is `1`, the chrome wi
137
137
138
138
3. For each page add a new class and declare the locators. Static locators can be class variables. Dynamic locators can be separate methods.
3. For each page add a new class and each page class should inherit the locators class of the same page
176
176
177
-
```python
177
+
```
178
178
from Locators.amazon_home_page import AmazonHomePageLocator
179
179
180
180
@@ -195,7 +195,7 @@ class AmazonHomePage(AmazonHomePageLocator):
195
195
196
196
1. Define the tests inside the Tests folder. Create a new `.py` file and import the required modules inside (depending on the requirement). Mainly require the page modules inside the test file. It is not recommended to import locator modules since we can access the locators from the page module.
197
197
198
-
```python
198
+
```
199
199
import allure
200
200
import pytest
201
201
import time
@@ -208,7 +208,7 @@ from selpy.variable import Var
208
208
209
209
2. It is suggested to mention the allure feature name, severity, pytest's markers to the test. This allows us to have better reporting and dynamic way to run in the future.
Use `allure.step("step name")` to have a detailed reporting in allure.
233
233
234
-
3. Append the method name for the test as `test_` only then it will be taken as a test case. This has been configured in ```pytest.ini``` as,
234
+
3. Append the method name for the test as `test_` only then it will be taken as a test case. This has been configured in `pytest.ini` as,
235
235
236
-
```ini
236
+
```
237
237
markers =
238
238
sanity: sanity tests marker
239
239
regression: regression tests marker
@@ -257,7 +257,7 @@ Allure configurations and pytest's default report has been wired here.
257
257
258
258
4. A file `conftest.py` should be created inside the Tests folder. In this file we can have the run before each, run before each module, run during and after pytest setup methods. Adding screenshot to the testcases is handled by,
259
259
260
-
```python
260
+
```
261
261
@pytest.fixture(autouse=True)
262
262
def before_each():
263
263
print('*-* Before each INITIALIZATION')
@@ -278,7 +278,7 @@ The fixture param `autouse=True` ensures that this block is invoked only once fo
278
278
279
279
Closing of all the drivers has been handled like,
280
280
281
-
```python
281
+
```
282
282
@pytest.fixture(scope='module', autouse=True)
283
283
def before_module():
284
284
print('*-* Before module INITIALIZATION')
@@ -292,7 +292,7 @@ The param `scope='module'`ensures that this block is invoked only once for each
292
292
293
293
5. We used home grown pypi published module `selpy` for Page Object Model support as well as snap support. To use that module data files path has to be set, this is done by,
@@ -304,7 +304,7 @@ This ensures that this data has been set before pytest is being invoked only onc
304
304
305
305
6. Assert using pytest's default assertion method. Make sure you have a proper description to the assertion, so that once it is failed the failure message is proper.
306
306
307
-
```python
307
+
```
308
308
assert (AmazonHomePage.is_home_page_displayed() is True), "Amazon home page is not displayed"
309
309
```
310
310
@@ -326,20 +326,20 @@ To use the snap mode, you need to use `selpy` [selpy](https://pypi.org/project/s
326
326
327
327
1. Declare the dictionary where the UI texts/data is to be stored during the test run.
0 commit comments