-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_product_page.py
98 lines (84 loc) · 4.82 KB
/
test_product_page.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import pytest
import time
from .pages.basket_page import BasketPage
from .pages.login_page import LoginPage
from .pages.product_page import ProductPage
@pytest.mark.need_review
@pytest.mark.parametrize('link', ["http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=offer0",
"http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=offer1",
"http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=offer2",
"http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=offer3",
"http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=offer4",
"http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=offer5",
"http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=offer6",
pytest.param("http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=offer7",marks=pytest.mark.xfail),
"http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=offer8",
"http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=offer9"])
def test_guest_can_add_product_to_basket(browser, link):
assert "promo=offer" in link, f"{link} the link does not contain promo=newYear"
page = ProductPage(browser, link)
page.open()
page.should_be_cart_link()
page.should_be_product_info()
page.add_product_to_cart()
page.solve_quiz_and_get_code()
page.check_added_product_name_with_alert()
page.check_price_pr_info_with_alert()
def test_guest_should_see_login_link_on_product_page(browser):
link = "http://selenium1py.pythonanywhere.com/en-gb/catalogue/the-city-and-the-stars_95/"
page = ProductPage(browser, link)
page.open()
page.should_be_login_link()
@pytest.mark.need_review
def test_guest_can_go_to_login_page_from_product_page(browser):
link = "http://selenium1py.pythonanywhere.com/en-gb/catalogue/the-city-and-the-stars_95/"
page = ProductPage(browser, link)
page.open()
page.go_to_login_page()
# Открываем страницу товара
# Переходим в корзину по кнопке в шапке сайта
# Проверяем, что в корзине нет товаров
# Проверяем, что есть текст на английском о том, что корзина пуста
@pytest.mark.need_review
def test_guest_cant_see_product_in_basket_opened_from_product_page(browser):
link = "http://selenium1py.pythonanywhere.com/en-gb/catalogue/the-city-and-the-stars_95/"
page = ProductPage(browser, link)
page.open()
page.go_to_cart_page()
cart_page = BasketPage(browser, browser.current_url)
cart_page.cart_should_be_empty()
cart_page.cart_should_have_empty_message()
class TestUserAddToBasketFromProductPage():
@pytest.fixture(scope="function", autouse=True)
def setup(self, browser):
link = 'http://selenium1py.pythonanywhere.com/accounts/login/'
page = LoginPage(browser, link)
page.open()
page.register_new_user(str(time.time()) + "@test.com", '123QWEasd123')
page.should_be_authorized_user()
# Открываем страницу товара
# Проверяем, что нет сообщения об успехе с помощью is_not_element_present
def test_user_cant_see_success_message(self, browser):
link = 'http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/'
page = ProductPage(browser, link)
page.open()
page.should_not_be_success_message()
# Открываем страницу товара
# Проверяем, есть ли кнопка "Добавить в корзину"
# Проверяем, есть ли основная информация о товаре
# Добавляем в корзину
# Получаем код
# Проверяем название товара
# Проверяем цену товара
@pytest.mark.need_review
def test_user_can_add_product_to_basket(self, browser):
link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=newYear2019"
# инициализируем Page Object, передаем в конструктор экземпляр драйвера и url адрес
page = ProductPage(browser, link)
page.open()
page.should_be_cart_link()
page.should_be_product_info()
page.add_product_to_cart()
page.solve_quiz_and_get_code()
page.check_added_product_name_with_alert()
page.check_price_pr_info_with_alert()