Esempio n. 1
0
class CatalogPage(BasePage):
    def __init__(self, context):
        super().__init__(context)

        self.product_title = Element(By.XPATH, '//a[contains(text(), "{}")]',
                                     context)

    def find_product_and_open_pdp(self, product_name):
        self.product_title.set_parameters(product_name)
        self.product_title.click()
Esempio n. 2
0
class ProductPage(BasePage):
    def __init__(self, context):
        super().__init__(context)

        self.add_to_cart_button = Element(By.NAME, 'add_cart', context)

        self.pdp_title = Element(
            By.XPATH, '//h3[contains(@class, "pdp__title")]/parent::div',
            context)

    def add_product_to_cart(self):
        self.add_to_cart_button.click()

    def check_if_pdp_title_contains_text(self, text):
        self.pdp_title.is_element_visible()
        title = self.pdp_title.text()

        if text not in title:
            raise Exception(
                f'PDP title: {title} does not contain text: {text}')
Esempio n. 3
0
class LoginPage(BasePage):

    def __init__(self, context):
        super().__init__(context)

        self.email_field = Element(
            By.NAME, 'username', context
        )

        self.password_field = Element(
            By.NAME, 'password', context
        )

        self.next_button = Element(
            By.ID, 'idp-discovery-submit', context
        )

        self.login_button = Element(
            By.ID, 'okta-signin-submit', context
        )

    def fill_email_field(self, email):
        self.email_field.value(email)

    def fill_password_field(self, password):
        self.password_field.value(password)

    def click_next_button(self):
        self.next_button.click()

    def click_login_button(self):
        self.login_button.click()

    def login_user(self, **kwargs):
        self.fill_email_field(kwargs['email'])
        self.click_next_button()
        self.fill_password_field(kwargs['password'])
        self.click_login_button()
Esempio n. 4
0
class CartPage(BasePage):
    def __init__(self, context):
        super().__init__(context)

        self.delete_product_icon = Element(By.ID, 'id_form-0-DELETE', context)

        self.confirm_deleting_product_button = Element(
            By.XPATH, '//button[contains(text(), "Confirm")]', context)
        self.cart_content = Element(By.XPATH,
                                    '//div[@class="checkout__main-content"]',
                                    context)

        self.empty_cart_message = Element(
            By.XPATH,
            '//p[contains(@class, "checkout-container__headline-empty")]',
            context)

        self.empty_cart_message_text = 'Your cart is empty'

    def click_delete_product_icon(self):
        self.delete_product_icon.click()

    def remove_products_from_cart(self):
        self.click_delete_product_icon()
        self.confirm_deleting_product_button.click()

    def check_if_cart_is_not_empty(self):
        self.cart_content.is_element_visible()
        assert_that(self.cart_content.is_element_visible(), equal_to(True),
                    'Cart is empty!')

    def check_empty_cart_message(self):
        self.empty_cart_message.is_element_visible()
        message = self.empty_cart_message.text()
        assert_that(
            message, equal_to(self.empty_cart_message_text),
            f'Message text {message} is not equal to expected text: {self.empty_cart_message_text}'
        )
Esempio n. 5
0
class BasePage:
    URL = ""

    def __init__(self, context):
        self.context = context

        # MENU OPTIONS
        self.login_button = Element(
            By.XPATH, '//div[contains(@class, "header-menu__logged-out")]',
            context)

        self.cart_icon = Element(
            By.XPATH, '//div[contains(@class,"js-cart-menu-container")]',
            context)

        self.go_to_checkout_button = Element(
            By.XPATH, '//a[contains(text(),"Go to Checkout")]', context)

        self.cookie_button = Element(By.XPATH,
                                     '//input[@value="Agree and Proceed"]',
                                     context)

        self.country_modal_accept_button = Element(
            By.XPATH, '//a[contains(text(),"I understand")]', context)

    def open(self):
        self.context.browser.get(self.context.base_e2e_url + self.URL)

    def click_login_button(self):
        self.login_button.click()

    def accept_cookie(self):
        self.cookie_button.click()

    def accept_country_modal(self):
        self.country_modal_accept_button.click()

    def go_to_checkout(self):
        self.cart_icon.mouse_hoover()
        self.go_to_checkout_button.click()