-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_product_page.py
More file actions
93 lines (73 loc) · 3.07 KB
/
Copy pathtest_product_page.py
File metadata and controls
93 lines (73 loc) · 3.07 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import pytest
import time
from .pages.basket_page import BasketPage
from .pages.login_page import LoginPage
from .pages.product_page import ProductPage
# LINK_BOOK_2 = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/"
LINK_BOOK = "http://selenium1py.pythonanywhere.com/catalogue/the-city-and-the-stars_95/"
LINK_LOGIN = "https://selenium1py.pythonanywhere.com/accounts/login/"
LINK_BOOK_PROMO = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=offer0"
LINK_PROMO = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=offer"
class TestUserAddToBasketFromProductPage:
@pytest.fixture(scope="function", autouse=True)
def setup(self, browser):
login_page = LoginPage(browser, LINK_LOGIN)
login_page.open()
email = str(time.time()) + "@fakemail.org"
password = str(time.time())
login_page.register_new_user(email, password)
login_page.should_be_authorized_user()
@pytest.mark.need_review
def test_user_can_add_product_to_basket(self, browser):
page = ProductPage(browser, LINK_BOOK)
page.open()
page.add_product_to_basket()
def test_user_cant_see_success_message(self, browser):
page = ProductPage(browser, LINK_BOOK)
page.open()
page.should_not_be_success_message()
@pytest.mark.need_review
def test_guest_can_add_product_to_basket(browser):
page = ProductPage(browser, LINK_BOOK_PROMO)
page.open()
page.add_product_to_basket()
@pytest.mark.skip
@pytest.mark.parametrize('promo', [*range(7),
pytest.param("7", marks=pytest.mark.xfail),
*range(8, 10)])
def test_guest_can_add_product_to_basket_parametrize(browser, promo):
link = f"{LINK_PROMO}{promo}"
page = ProductPage(browser, link)
page.open()
page.add_product_to_basket()
@pytest.mark.skip
def test_guest_cant_see_success_message_after_adding_product_to_basket(browser):
page = ProductPage(browser, LINK_BOOK)
page.open()
page.add_product_to_basket()
page.should_not_be_success_message()
@pytest.mark.skip
def test_message_disappeared_after_adding_product_to_basket(browser):
page = ProductPage(browser, LINK_BOOK)
page.open()
page.add_product_to_basket()
page.should_dissapear_of_success_message()
def test_guest_should_see_login_link_on_product_page(browser):
page = ProductPage(browser, LINK_BOOK)
page.open()
page.should_be_login_link()
@pytest.mark.need_review
def test_guest_can_go_to_login_page_from_product_page(browser):
page = ProductPage(browser, LINK_BOOK)
page.open()
page.go_to_login_page()
login_page = LoginPage(browser, browser.current_url)
login_page.should_be_login_page()
@pytest.mark.need_review
def test_guest_cant_see_product_in_basket_opened_from_product_page(browser):
page = ProductPage(browser, LINK_BOOK)
page.open()
page.go_to_basket_page()
basket_page = BasketPage(browser, browser.current_url)
basket_page.should_not_be_product_in_basket()
basket_page.basket_is_empty()