-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_product_page.py
More file actions
67 lines (61 loc) · 2.92 KB
/
test_product_page.py
File metadata and controls
67 lines (61 loc) · 2.92 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
from pages.product_page import ProductPage
from pages.locators import ProductPageLocators
from pages.login_page import LoginPage
from pages.basket_page import BasketPage
import time
import pytest
@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",
])
def test_guest_can_add_product_to_basket(browser, link):
page = ProductPage(browser, link)
page.open()
page.add_to_basket()
page.solve_quiz_and_get_code()
time.sleep(3)
page.should_be_added_to_basket()
page.product_name_and_added_product_name_are_the_same()
page.product_price_and_added_product_price_are_the_same()
@pytest.mark.success_message
class TestSuccessMassageForGuest():
@pytest.mark.xfail(reason="This is a demonstration of XFAIL mark usage")
def test_guest_cant_see_success_message_after_adding_product_to_basket(self, browser):
link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=offer0"
page = ProductPage(browser, link)
page.open()
page.add_to_basket()
page.solve_quiz_and_get_code()
time.sleep(3)
page.is_not_element_present(*ProductPageLocators.PRODUCT_IS_ADDED_MESSAGE)
@pytest.mark.xfail(reason="Another demonstration of XFAIL mark usage")
def test_success_message_dissapear_after_adding_product_to_basket(self, browser):
link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=offer0"
page = ProductPage(browser, link)
page.open()
page.add_to_basket()
page.solve_quiz_and_get_code()
time.sleep(3)
page.is_disappeared(*ProductPageLocators.PRODUCT_IS_ADED_MESSAGE)
@pytest.mark.login_guest
class TestLoginFromProductPage():
def test_guest_should_see_login_link_on_product_page(self, 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()
def test_guest_can_go_to_login_page_from_product_page(self, 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()
login_page = LoginPage(browser, browser.current_url)
login_page.should_be_login_url()
@pytest.mark.smoke
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_basket_link()
basket_page.should_be_empty_basket_message()