Esempio n. 1
0
class TestProductPage:
    @pytest.fixture()
    def setup(self, driver_setup):
        self.results_page = ResultsPage(driver_setup)
        self.product_page = ProductPage(driver_setup)
        self.login_page = LoginPage(driver_setup)
        self.wish = WishlistPage(driver_setup)
        self.product = "jeans"

    @pytest.mark.tcid15
    def test_add_product_to_cart_as_user(self, setup):
        self.login_page.goto()
        self.login_page.login()
        self.results_page.goto_product(self.product)
        self.product_page.add_to_bag(select_type="dropdown")
        assert self.product_page.verify_added_to_bag()
        if AssertionError:
            self.login_page.driver.take_screenshot(
                name="test_add_product_to_cart_as_user")

    @pytest.mark.tcid16
    def test_add_product_to_wishlist_as_user(self, setup):
        self.login_page.goto()
        self.login_page.login()
        self.results_page.goto_product(self.product)
        product_name = self.product_page.get_product_title()
        self.product_page.add_to_wishlist(select_type="dropdown")
        assert self.wish.verify_product_in_wishlist(product_name)
        if AssertionError:
            self.login_page.driver.take_screenshot(
                name="test_add_product_to_wishlist_as_user")

    @pytest.mark.tcid17
    def test_add_product_to_cart_as_guest(self, setup):
        self.results_page.goto_product(self.product)
        self.product_page.add_to_bag(select_type="dropdown")
        assert self.product_page.verify_added_to_bag()
        if AssertionError:
            self.login_page.driver.take_screenshot(
                name="test_add_product_to_wishlist_as_user")

    @pytest.mark.tcid18
    def test_guest_must_login_to_wishlist_product(self, setup):
        self.results_page.goto_product(self.product)
        self.product_page.add_to_wishlist(select_type="dropdown")
        assert self.product_page.verify_login_prompt()
        if AssertionError:
            self.login_page.driver.take_screenshot(
                name="test_guest_must_login_to_wishlist_product")
Esempio n. 2
0
class TestAddDeliveryAddress(unittest.TestCase):

    root = os.path.dirname(os.path.dirname(__file__))
    data_path = os.path.join(root, "..", "test_data", "AddressRecords.csv")

    @pytest.fixture()
    def setup(self, driver_setup):
        self.login_page = LoginPage(driver_setup)
        self.results_page = ResultsPage(driver_setup)
        self.product_page = ProductPage(driver_setup)
        self.cart = CartPage(driver_setup)
        self.delivery_page = DeliveryPage(driver_setup)
        self.product = "jeans"


    @pytest.fixture()
    def preconditions(self, setup):
        if not self.login_page.verify_logged_in():
            self.login_page.goto()
            self.login_page.login()
        self.results_page.goto_product(self.product)
        self.product_page.add_to_bag(select_type="dropdown")
        self.cart.goto()
        self.cart.goto_checkout_page()
        yield
        self.delivery_page.go_back_to_home_page()


    @pytest.mark.tcid25
    @data(*getCSVData(data_path))
    @unpack
    @pytest.mark.usefixtures("setup", "preconditions")
    def test_add_valid_delivery_details(self, fullAddress, Postcode, PhoneNum):
        self.delivery_page.enter_full_delivery_details(phone=PhoneNum, postcode=Postcode, full_address=fullAddress)
        assert self.delivery_page.verify_valid_delivery_details()
        if AssertionError:
            self.delivery_page.driver.take_screenshot(name="test_add_valid_delivery_details")
Esempio n. 3
0
class TestPayWithCreditCard(unittest.TestCase):

    root = os.path.dirname(os.path.dirname(__file__))
    data_path = os.path.join(root, "..", "test_data", "CCRecords.csv")

    @pytest.fixture()
    def setup(self, driver_setup):
        self.login_page = LoginPage(driver_setup)
        self.results_page = ResultsPage(driver_setup)
        self.product_page = ProductPage(driver_setup)
        self.cart = CartPage(driver_setup)
        self.payment_page = PaymentPage(driver_setup)
        self.delivery_page = DeliveryPage(driver_setup)
        self.product = "jeans"


    @pytest.fixture()
    def preconditions(self, setup):
        self.login_page.goto()
        self.login_page.login()
        self.results_page.goto_product(self.product)
        self.product_page.add_to_bag(select_type="dropdown")
        self.cart.goto()
        self.cart.goto_checkout_page()
        self.delivery_page.enter_full_delivery_details()


    @data(*getCSVData(data_path))
    @unpack
    @pytest.mark.tcid30
    @pytest.mark.usefixtures("setup", "preconditions")
    def test_pay_with_valid_card(self, ccNum, ccCVV, ccExp):
        self.payment_page.place_order(payment_options="card", curd_num=ccNum,
                                      expiry_date=ccExp, cvv=ccCVV)
        assert self.payment_page.verify_successful_payment()
        if AssertionError:
            self.delivery_page.driver.take_screenshot(name="test_pay_with_valid_card")