forked from hs3city/test_automation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
64 lines (49 loc) · 1.68 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
There are module with fixtures for UI testing.
"""
import string
from dataclasses import dataclass
from random import choice
import names
import pytest
from main import Constants
pytest_plugins = [
"fixtures.drivers.web_driver",
]
@dataclass
class User:
"""The simple data class for User."""
first_name: str
last_name: str
email: str
password: str
@pytest.fixture
def generate_password() -> str:
"""Generate password with ten letters, ten digits and ten punctuation e.g. KkQkIGmsVx1530668957(|+$,_('~{"""
return "".join(choice(string.ascii_letters) for i in range(10)) + \
"".join(choice(string.digits) for i in range(10)) + \
"".join(choice(string.punctuation) for i in range(10))
@pytest.fixture
def create_user_with_credentials(generate_password: str):
"""
Generate new user with credentials.
:return: User object
"""
first_name = names.get_first_name()
last_name = names.get_last_name()
email = f"{first_name}.{last_name}@gmail.com"
return User(first_name, last_name, email, generate_password)
@pytest.fixture
def get_default_user():
"""
Return user with has been registered on the system.
:return: User object
"""
return User("Ronald", "Longley", "[email protected]", "QWERTY1234567890!@#$")
@pytest.fixture(autouse=False)
def login_user(web_driver, get_default_user):
user = get_default_user
web_driver.find_element(*Constants.ACCOUNT_BUTTON).click()
web_driver.find_element(*Constants.USERNAME_INPUT_LOG).send_keys(user.email)
web_driver.find_element(*Constants.PASSWORD_INPUT_LOG).send_keys(user.password)
web_driver.find_element(*Constants.LOGIN_BUTTON).click()