Skip to content

Commit 1504f88

Browse files
2 parents 01ffc9d + aea5db7 commit 1504f88

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

README.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
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).
44

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.
66

77
More details of this module can be refered in [selpy](https://pypi.org/project/selpy/) or [repo](https://github.com/nareshnavinash/selpy)
88

@@ -42,31 +42,31 @@ More details of this module can be refered in [selpy](https://pypi.org/project/s
4242
## To Run the tests
4343
For a simple run of all the test files in normal mode, try
4444

45-
```shell script
45+
```
4646
pytest
4747
```
4848

4949
To run the tests in snap mode (to save the UI texts to the dynamic file)
50-
```shell script
50+
```
5151
snap=1 pytest
5252
```
5353
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.
5454

5555
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)
5656

57-
```shell script
57+
```
5858
pytest -s -v -n=2
5959
```
6060

6161
To Run the tests in parallel mode for the available test files along with browser specification, try
6262

63-
```shell script
63+
```
6464
browser=chrome pytest -s -v -n=2
6565
```
6666

6767
To Run the tests in parallel mode for the available test files in headless mode, try
6868

69-
```shell script
69+
```
7070
headless=1 browser=chrome pytest -s -v -n=2
7171
```
7272

@@ -75,14 +75,14 @@ This will run the tests in headless mode
7575
## To open allure results
7676
Allure is a open source framework for reporting the test runs. To install allure in mac, use the following steps
7777

78-
```shell script
78+
```
7979
brew cask install adoptopenjdk
8080
brew install allure
8181
```
8282

8383
To view the results for the test run, use
8484

85-
```shell script
85+
```
8686
allure serve reports/allure
8787
```
8888

@@ -98,7 +98,7 @@ For better illustration on the testcases, allure reports has been integrated. Al
9898
## Jenkins Integration with Docker images
9999
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,
100100

101-
```shell script
101+
```
102102
#!/usr/bin/python3
103103
python --version
104104
cd <path_to_the_project>
@@ -108,7 +108,7 @@ headless=1 pytest -s -v -n 4
108108

109109
In Jenkins pipeline, try to add the following snippet to execute the tests,
110110

111-
```shell script
111+
```
112112
pipeline {
113113
agent { docker { image 'python:3.7.6' } }
114114
stages {
@@ -137,7 +137,7 @@ In `Data/GlobalData/global_data.yml` file, if the headless is `1`, the chrome wi
137137

138138
3. For each page add a new class and declare the locators. Static locators can be class variables. Dynamic locators can be separate methods.
139139

140-
```python
140+
```
141141
class AmazonHomePageLocator:
142142
amazon_logo = Locator("css selector", "div#nav-logo a[aria-label='Amazon']")
143143
amazon_search_categories = Locator("css selector", "div.nav-search-scope select.nav-search-dropdown")
@@ -174,7 +174,7 @@ CLASS NAME - 'class name'
174174

175175
3. For each page add a new class and each page class should inherit the locators class of the same page
176176

177-
```python
177+
```
178178
from Locators.amazon_home_page import AmazonHomePageLocator
179179
180180
@@ -195,7 +195,7 @@ class AmazonHomePage(AmazonHomePageLocator):
195195

196196
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.
197197

198-
```python
198+
```
199199
import allure
200200
import pytest
201201
import time
@@ -208,7 +208,7 @@ from selpy.variable import Var
208208

209209
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.
210210

211-
```python
211+
```
212212
@allure.feature("Feature name")
213213
@allure.severity('Critical')
214214
@pytest.mark.regression
@@ -223,17 +223,17 @@ def test_amazon_book_search_001():
223223

224224
To run the test with marker you can execute as
225225

226-
```shell script
226+
```
227227
pytest -v -m regression
228228
# or
229229
pytest -v -m ui
230230
```
231231

232232
Use `allure.step("step name")` to have a detailed reporting in allure.
233233

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,
235235

236-
```ini
236+
```
237237
markers =
238238
sanity: sanity tests marker
239239
regression: regression tests marker
@@ -257,7 +257,7 @@ Allure configurations and pytest's default report has been wired here.
257257

258258
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,
259259

260-
```python
260+
```
261261
@pytest.fixture(autouse=True)
262262
def before_each():
263263
print('*-* Before each INITIALIZATION')
@@ -278,7 +278,7 @@ The fixture param `autouse=True` ensures that this block is invoked only once fo
278278

279279
Closing of all the drivers has been handled like,
280280

281-
```python
281+
```
282282
@pytest.fixture(scope='module', autouse=True)
283283
def before_module():
284284
print('*-* Before module INITIALIZATION')
@@ -292,7 +292,7 @@ The param `scope='module'`ensures that this block is invoked only once for each
292292

293293
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,
294294

295-
```python
295+
```
296296
from selpy.store import Store
297297
def pytest_configure(config):
298298
Store.global_data_path = os.path.dirname(os.path.abspath(__file__)).replace("/Tests", "") + '/Data/GlobalData/global_data.yml'
@@ -304,7 +304,7 @@ This ensures that this data has been set before pytest is being invoked only onc
304304

305305
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.
306306

307-
```python
307+
```
308308
assert (AmazonHomePage.is_home_page_displayed() is True), "Amazon home page is not displayed"
309309
```
310310

@@ -326,20 +326,20 @@ To use the snap mode, you need to use `selpy` [selpy](https://pypi.org/project/s
326326

327327
1. Declare the dictionary where the UI texts/data is to be stored during the test run.
328328

329-
```python
329+
```
330330
ui_dynamic_data = {}
331331
ui_dynamic_data["amazon_product_title"] = AmazonProductPage.amazon_product_title.texts_as_string()
332332
```
333333

334334
2. Initiate a class variable with the file name against which you need to verify the UI data.
335335

336-
```python
336+
```
337337
dynamic_variable = Var("amazon_book_search_result_dynamic.yml", "dynamic")
338338
```
339339

340340
3. To compare the UI data with the file use the `compare` method that comes along with the `dynamic_variable`
341341

342-
```python
342+
```
343343
dynamic_variable.compare(ui_dynamic_data)
344344
```
345345

@@ -353,7 +353,7 @@ This will compare and report it to allure and assertion has been done within tha
353353

354354
For static code analyser I used flake8. To check the configurations view (.flake8)[.flake8] file. To check on the code status execte,
355355

356-
```shell script
356+
```
357357
flake8
358358
```
359359

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
theme: jekyll-theme-hacker
1+
theme: jekyll-theme-cayman

0 commit comments

Comments
 (0)