-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_product_page.py
More file actions
127 lines (109 loc) · 5.65 KB
/
Copy pathtest_product_page.py
File metadata and controls
127 lines (109 loc) · 5.65 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
from .pages.product_page import ProductPage
from .pages.basket_page import BasketPage
from .pages.search_page import SearchPage
from .pages.login_page import LoginPage
from .pages.base_page import BasePage
import pytest
import faker
@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_bo_basket(browser, link):
page = ProductPage(browser, link)
page.open()
page.adding_a_product_to_basket()
page.solve_quiz_and_get_code()
page.should_be_item_added_to_basket()
page.should_be_compare_the_price_of_the_product_in_sum_basket()
@pytest.mark.xfail
def test_guest_cant_see_success_message_after_adding_product_to_basket(browser):
link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/"
page = ProductPage(browser, link)
page.open()
page.adding_a_product_to_basket()
page.should_not_be_success_message()
def test_guest_cant_see_success_message(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.xfail
def test_message_disappeared_after_adding_product_to_basket(browser):
link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/"
page = ProductPage(browser, link)
page.open()
page.adding_a_product_to_basket()
page.should_be_the_message_disappears()
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_basket_page()
basket_page = BasketPage(browser, browser.current_url)
basket_page.should_be_empty_basket()
@pytest.mark.parametrize('langs', ["ar", "ca", "cs", "da", "de", "en-gb",
"el", "es", "fi", "fr", "it", "ko", "nl",
"pl", "pt", "pt-br", "ro", "ru", "sk", "uk",
pytest.param('zh-hans', marks=pytest.mark.xfail)])
def test_guest_switches_interface_language(browser, langs):
link = "http://selenium1py.pythonanywhere.com/en-gb/catalogue/the-city-and-the-stars_95/"
page = ProductPage(browser, link)
page.open()
page.choose_a_language(langs)
page.switch_language()
page.should_be_language_in_url(langs)
def test_searches_for_a_product_using_search(browser):
link = "http://selenium1py.pythonanywhere.com/en-gb/catalogue/the-city-and-the-stars_95/"
what_search = "Coders at Work"
page = ProductPage(browser, link)
page.open()
page.entering_a_value_in_the_search_field(what_search)
page.start_search_by_button()
search_page = SearchPage(browser, browser.current_url)
search_page.search_the_result_on_the_search_page(what_search)
@pytest.mark.register_user
class TestUserAddToBasketFromProductPage():
@pytest.fixture(scope="function", autouse=True)
def setup(self, browser):
f = faker.Faker()
email = f.email()
password = "123mm!24234235gg"
self.link = "http://selenium1py.pythonanywhere.com/accounts/login/"
page = LoginPage(browser, self.link)
page.open()
page.register_new_user(email, password)
page.should_be_authorized_user()
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 = ProductPage(browser, link)
page.open()
page.adding_a_product_to_basket()
page.solve_quiz_and_get_code()
page.should_be_item_added_to_basket()
page.should_be_compare_the_price_of_the_product_in_sum_basket()