Skip to content

Commit 2bfd766

Browse files
committed
sync version
1 parent a732ebe commit 2bfd766

File tree

14 files changed

+192
-105
lines changed

14 files changed

+192
-105
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Add required reviewers
2+
* @Goraved

.github/pull_request_template.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## Main idea of the pull request
2+
3+
{text}
4+
5+
## Changes proposed in the pull request (required)
6+
7+
1.
8+
2.
9+
3.
10+
11+
## Links & attachments (optional)
12+
13+
-
14+
-
15+
16+
17+
### Notes:
18+
- @Goraved should be added to the assignees;
19+
- Tests should be passed;
20+
- Linter should be passed.

.github/workflows/pylint.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Pylint
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Set up Python 3.8
13+
uses: actions/setup-python@v1
14+
with:
15+
python-version: 3.8
16+
- name: Install dependencies
17+
run: |
18+
python -m pip install --upgrade pip
19+
pip install -r requirements.txt
20+
- name: Test with pylint
21+
run: |
22+
pylint-fail-under *.py **/*.py --fail_under 9.8
23+

.github/workflows/pytest.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Python package
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
python-version: [3.8]
12+
13+
steps:
14+
- name: Install dependencies
15+
run: |
16+
python -m pip install --upgrade pip
17+
pip install flake8 pytest
18+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
19+
- name: Test with pytest
20+
env:
21+
TOKEN: ${{ secrets.TOKEN }}
22+
SELENIUM_HUB_HOST: 'http://localhost:4444/wd/hub'
23+
GITHUB_RUN: True
24+
run: |
25+
pytest

.pylintrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[FORMAT]
2+
max-line-length=120
3+
4+
# Docstrings
5+
disable=C0114,C0115,C0116,W0603
6+
7+
[MASTER]
8+
init-hook="from pylint.config import find_pylintrc; import os, sys; sys.path.append(os.path.dirname(find_pylintrc()))"

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ RUN pip install --upgrade pip && \
4343
pip install virtualenv && \
4444
virtualenv --python=/usr/bin/python3 /opt/venv && \
4545
. /opt/venv/bin/activate && \
46-
python3.7 -m pip install -r requirements.txt --quiet
46+
python3.7 -m pip install -r requirements.txt --quiet && \
47+
python3.7 -m playwright install
4748

4849
WORKDIR /app

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ Just a [Playwright Python](https://github.com/Microsoft/playwright-python) tool
55
1. Run tests `execute_tests.sh`
66

77
## Notes:
8-
I didn't enjoy this tool, cause it's very complicated. It totally looks like it just has been translated
9-
from JS Playwright and need to wright on Python usign JS style. So annoying. But this tools is pretty
10-
fast.
8+
Pretty interesting and fast-growing tool for test automation. It can have some troubles with the first setup
9+
(especially with Docker), but generally this tool faster than Selenium and have pretty nice facade methods out of the box.
1110

12-
Anyway, I won't recommend this tool to young Python AQA engineers.
11+
It's hard to say if I can recommend this tool to young Python AQA engineers because Selenium is a standard
12+
and supports by W3C. But if you have a small project, then it can be a wise choice to use Playwright.
1313

1414
### [Video](https://drive.google.com/file/d/1K2uUlXASjPOiCbCbYkqmuHN26em7bPHs/view?usp=sharing)
1515

execute_tests.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#!/usr/bin/env bash
22
source venv/bin/activate
3-
echo "-> Installing dependeincies"
3+
echo "-> Installing dependencies"
44
pip install -r requirements.txt --quiet
5+
echo "-> Installing Playwright browsers"
6+
python3.7 -m playwright install
57

68
echo "-> Removing old Allure results"
79
rm -r allure-results/* || echo "No results"

page_objects/base_page.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import allure
2-
from playwright.helper import TimeoutError as TE
2+
from playwright.helper import TimeoutError as TError
33
from playwright.page import Page
44

55

@@ -8,46 +8,47 @@ def __init__(self, page: Page):
88
self.page = page
99

1010
@allure.step('Click locator - {locator}')
11-
async def click(self, locator):
12-
await self.page.click(locator)
11+
def click(self, locator: str):
12+
self.page.click(locator)
1313

1414
@allure.step('Check checkbox locator - {locator}')
15-
async def check(self, locator):
16-
await self.page.check(locator)
15+
def check(self, locator: str):
16+
self.page.check(locator)
1717

1818
@allure.step('Uncheck checkbox locator - {locator}')
19-
async def uncheck(self, locator):
20-
await self.page.check(locator)
19+
def uncheck(self, locator: str):
20+
self.page.check(locator)
2121

2222
@allure.step('Hover locator - {locator}')
23-
async def hover(self, locator):
24-
await self.page.hover(locator)
23+
def hover(self, locator: str):
24+
self.page.hover(locator)
2525

2626
@allure.step('Go to url - {url}')
27-
async def go_to_url(self, url):
28-
await self.page.goto(url)
27+
def go_to_url(self, url: str):
28+
self.page.goto(url)
2929

3030
@allure.step('Type text - {text} into locator - {locator}')
31-
async def type(self, locator, text):
32-
await self.click(locator)
33-
await self.page.fill(locator, text)
31+
def type(self, locator: str, text: str):
32+
self.click(locator)
33+
self.page.fill(locator, text)
3434

3535
@allure.step('Select option - {option} in locator - {locator}')
36-
async def select_option(self, locator, option):
37-
await self.page.selectOption(locator, option)
36+
def select_option(self, locator: str, option: str):
37+
self.page.selectOption(locator, option)
3838

3939
@allure.step('Is element - {locator} present')
40-
async def is_element_present(self, locator):
40+
def is_element_present(self, locator: str) -> bool:
4141
try:
42-
await self.page.waitForSelector(locator)
42+
self.page.waitForSelector(locator)
4343
return True
44-
except TE:
44+
except TError:
4545
return False
4646

4747
@allure.step('Is element - {locator} hidden')
48-
async def is_element_present(self, locator):
48+
def is_element_hidden(self, locator: str) -> bool:
4949
try:
50-
await self.page.waitForSelector(locator, {'state': 'hidden'})
50+
self.page.waitForSelector(locator, state='hidden')
5151
return True
52-
except TE:
52+
except TError:
5353
return False
54+

page_objects/registation/registration_object.py

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

66

77
class RegistrationPage(BasePage):
8-
async def register_account(self):
9-
await self.type(RegistrationLocators.EMAIL_INPUT, f'goraved@{randint(1000, 99999)}.com')
10-
await self.click(RegistrationLocators.CREATE_BTN)
11-
await self.click(RegistrationLocators.GENDER_OPTION)
12-
await self.type(RegistrationLocators.CUSTOMER_FIRST_NAME_INPUT, "Test")
13-
await self.type(RegistrationLocators.CUSTOMER_LAST_NAME_INPUT, "Goraved")
14-
await self.type(RegistrationLocators.PASSWORD_INPUT, "123asd")
15-
await self.select_option(RegistrationLocators.DAYS_SELECTOR, "1")
16-
await self.select_option(RegistrationLocators.MONTHS_SELECTOR, "1")
17-
await self.select_option(RegistrationLocators.YEARS_SELECTOR, "2020")
18-
await self.click(RegistrationLocators.AGREE_CHECKBOX)
19-
await self.click(RegistrationLocators.NEWSLETTER_CHECKBOX)
20-
await self.type(RegistrationLocators.FIRST_NAME_INPUT, 'Test')
21-
await self.type(RegistrationLocators.LAST_NAME_INPUT, 'Goraved')
22-
await self.type(RegistrationLocators.ADDRESS_INPUT, "street")
23-
await self.type(RegistrationLocators.CITY_INPUT, "test")
24-
await self.select_option(RegistrationLocators.STATE_SELECT, "1")
25-
await self.type(RegistrationLocators.POSTCODE_INPUT, "11111")
26-
await self.type(RegistrationLocators.OTHER_INPUT, "123")
27-
await self.type(RegistrationLocators.PHONE_INPUT, "123")
28-
await self.click(RegistrationLocators.ALIAS_BTN)
29-
await self.click(RegistrationLocators.SUBMIT_ACCOUNT_BTN)
8+
def register_account(self):
9+
self.type(RegistrationLocators.EMAIL_INPUT, f'goraved@{randint(1000, 99999)}.com')
10+
self.click(RegistrationLocators.CREATE_BTN)
11+
self.click(RegistrationLocators.GENDER_OPTION)
12+
self.type(RegistrationLocators.CUSTOMER_FIRST_NAME_INPUT, "Test")
13+
self.type(RegistrationLocators.CUSTOMER_LAST_NAME_INPUT, "Goraved")
14+
self.type(RegistrationLocators.PASSWORD_INPUT, "123asd")
15+
self.select_option(RegistrationLocators.DAYS_SELECTOR, "1")
16+
self.select_option(RegistrationLocators.MONTHS_SELECTOR, "1")
17+
self.select_option(RegistrationLocators.YEARS_SELECTOR, "2020")
18+
self.click(RegistrationLocators.AGREE_CHECKBOX)
19+
self.click(RegistrationLocators.NEWSLETTER_CHECKBOX)
20+
self.type(RegistrationLocators.FIRST_NAME_INPUT, 'Test')
21+
self.type(RegistrationLocators.LAST_NAME_INPUT, 'Goraved')
22+
self.type(RegistrationLocators.ADDRESS_INPUT, "street")
23+
self.type(RegistrationLocators.CITY_INPUT, "test")
24+
self.select_option(RegistrationLocators.STATE_SELECT, "1")
25+
self.type(RegistrationLocators.POSTCODE_INPUT, "11111")
26+
self.type(RegistrationLocators.OTHER_INPUT, "123")
27+
self.type(RegistrationLocators.PHONE_INPUT, "123")
28+
self.click(RegistrationLocators.ALIAS_BTN)
29+
self.click(RegistrationLocators.SUBMIT_ACCOUNT_BTN)

0 commit comments

Comments
 (0)