forked from yandex-praktikum/qa_python_page_object
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpage_object_practice_task1.py
More file actions
79 lines (58 loc) · 2.18 KB
/
page_object_practice_task1.py
File metadata and controls
79 lines (58 loc) · 2.18 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
# Class for the login page
class LoginPageAround:
email_field = (By.ID, 'email')
password_field = (By.ID, 'password')
sign_in_button = (By.CLASS_NAME, 'auth-form__button')
def __init__(self, driver):
self.driver = driver
def set_email(self, email):
self.driver.find_element(*self.email_field).send_keys(email)
def set_password(self, password):
self.driver.find_element(*self.password_field).send_keys(password)
def click_sign_in_button(self):
self.driver.find_element(*self.sign_in_button).click()
def login(self, email, password):
self.set_email(email)
self.set_password(password)
self.click_sign_in_button()
# Class for the main page
class HomePageAround:
# Create a locator for the Occupation field in the user profile
profile_description = ...
def __init__(self, driver):
self.driver = driver
# Wait for the Occupation field to appear
def wait_for_load_home_page(self):
WebDriverWait(self.driver, 3).until(expected_conditions.visibility_of_element_located(self.profile_description))
# Retrieve the value of the Occupation field
def get_description(self):
return ...
class TestAround:
driver = None
@classmethod
def setup_class(cls):
# Create a driver for Chrome
cls.driver = webdriver.Chrome()
def test_get_description(self):
# Open the test application page
self.driver.get('https://around-v1.nm.tripleten-services.com/signin?lng=en')
# Create a page object class for the login page
...
# log in
...
# Create a page object for the main page
...
# Wait for the main page to load
...
# Save the value of Occupation to description
description = ...
# Use assert to check that the actual value of Occupation matches the expected value
assert ...
@classmethod
def teardown_class(cls):
# Close the browser
...