def __init__(self, wait: WebDriverWait, root: WebElement):
     self._wait = wait
     self._title = BasePageElement(CartItemLoc.TITLE, wait=wait, root=root)
     self._description = BasePageElement(CartItemLoc.DESCRIPTION,
                                         wait=wait,
                                         root=root)
     self._price = BasePageElement(CartItemLoc.PRICE, wait=wait, root=root)
     self._inv_btn = BasePageElement(CartItemLoc.BTN, wait=wait, root=root)
Exemple #2
0
class Checkout:
    def __init__(self, wait: WebDriverWait):
        self._wait = wait
        self._subtotal = BasePageElement(CheckoutLoc.SUBTOTAL_LABEL, wait=wait)
        self._total = BasePageElement(CheckoutLoc.TOTAL_LABEL, wait=wait)
        self._cancel_btn = BasePageElement(CheckoutLoc.CANCEL_BTN, wait=wait)
        self._finish_btn = BasePageElement(CheckoutLoc.FINISH_BTN, wait=wait)
        self._success_msg = BasePageElement(CheckoutLoc.SUCCESS_MSG, wait=wait)
        self._title = BasePageElement(CheckoutLoc.TITLE_LABEL, wait=wait)

    def cancel_checkout(self):
        self._cancel_btn.click()

    def finish(self):
        self._finish_btn.click()

    def get_subtotal(self) -> str:
        return self._subtotal.get_text()

    def get_total(self) -> str:
        return self._total.get_text()

    def get_success_msg(self) -> str:
        return self._success_msg.get_text()

    def get_title(self) -> str:
        return self._title.get_text()
Exemple #3
0
class InventoryDetailsPage(InventoryItemMixin, BasePage):
    """Implements inventory item details"""

    def __init__(self, driver: WebDriver, timeout: int = 5):
        super().__init__(driver, _URL, timeout)
        self._title = BasePageElement(InventoryDetailsLoc.TITLE, wait=self._wait)
        self._description = BasePageElement(InventoryDetailsLoc.DESCRIPTION, wait=self._wait)
        self._price = BasePageElement(InventoryDetailsLoc.PRICE, wait=self._wait)
        self._inv_btn = BasePageElement(InventoryDetailsLoc.BTN, wait=self._wait)
        self._back_btn = BasePageElement(InventoryDetailsLoc.BACK_BTN, wait=self._wait)
        self.header = Header(self._wait)

    def back(self):
        """Go back to details page."""
        self._back_btn.click()
 def __init__(self, driver: WebDriver, timeout: int = 5):
     super().__init__(driver, _URL, timeout)
     self.__user = BasePageElement(LoginPageLoc.USER, wait=self._wait)
     self.__password = BasePageElement(LoginPageLoc.PASSWORD,
                                       wait=self._wait)
     self.__login = BasePageElement(LoginPageLoc.LOGIN, wait=self._wait)
     self.__error_msg = BasePageElement(LoginPageLoc.ERROR_MSG,
                                        wait=self._wait)
 def __init__(self, driver: WebDriver, timeout: int = 5):
     super().__init__(driver, _URL, timeout)
     self.header = Header(self._wait)
     self.products = CartItems(CartLoc.CART_ITEMS, self._wait)
     self.__title = BasePageElement(CartLoc.TITLE, self._wait)
     self.__ctn_shopping = BasePageElement(CartLoc.CTN_SHOPPING, self._wait)
     self.__remove_button = BasePageElement(CartLoc.REMOVE_BUTTON, self._wait)
     self.__checkout_btn = BasePageElement(CartLoc.CHECKOUT_BTN, self._wait)
Exemple #6
0
class InventoryItem(InventoryItemMixin):
    """Represents inventory item."""
    def __init__(self, wait: WebDriverWait, root: WebElement):
        self._wait = wait
        self._title = BasePageElement(InventoryItemLoc.TITLE,
                                      wait=wait,
                                      root=root)
        self._description = BasePageElement(InventoryItemLoc.DESCRIPTION,
                                            wait=wait,
                                            root=root)
        self._price = BasePageElement(InventoryItemLoc.PRICE,
                                      wait=wait,
                                      root=root)
        self._inv_btn = BasePageElement(InventoryItemLoc.BTN,
                                        wait=wait,
                                        root=root)

    def open_details(self):
        """Open product details"""
        self._title.click()
        return InventoryDetailsPage(self._wait._driver, self._wait._timeout)
class Header:
    """Represents inventory item."""
    def __init__(self, wait: WebDriverWait):
        self._wait = wait
        self._link = BasePageElement(HeaderLoc.LINK, wait=wait)
        self._badge = BasePageElement(HeaderLoc.BADGE, wait=wait)
        self._burger_btn = BasePageElement(HeaderLoc.BURGER_BTN, wait=wait)

    def get_total_cart_items(self) -> int:
        """Get total items in cart"""
        try:
            return int(self._badge.get_text())
        except Exception:
            return 0

    def goto_cart(self):
        """Go to cart."""
        self._link.click()

    def open_menu(self):
        """Open menu"""
        self._burger_btn.click()
Exemple #8
0
 def __init__(self, driver: WebDriver, timeout: int = 5):
     super().__init__(driver, _URL, timeout)
     self.__search_textbox = BasePageElement(GoogleLocators.SEARCH_TEXT_BOX,
                                             wait=self._wait)
     self.__search_btn = BasePageElement(GoogleLocators.SEARCH_BTN,
                                         wait=self._wait)
     self.__feeling_lucky_btn = BasePageElement(
         GoogleLocators.FEELING_LUCKY_BTN, wait=self._wait)
Exemple #9
0
 def __init__(self, driver: WebDriver, timeout: int = 5):
     super().__init__(driver, _URL, timeout)
     self._title = BasePageElement(InventoryDetailsLoc.TITLE, wait=self._wait)
     self._description = BasePageElement(InventoryDetailsLoc.DESCRIPTION, wait=self._wait)
     self._price = BasePageElement(InventoryDetailsLoc.PRICE, wait=self._wait)
     self._inv_btn = BasePageElement(InventoryDetailsLoc.BTN, wait=self._wait)
     self._back_btn = BasePageElement(InventoryDetailsLoc.BACK_BTN, wait=self._wait)
     self.header = Header(self._wait)
Exemple #10
0
class Google(BasePage):
    """Google base page."""
    def __init__(self, driver: WebDriver, timeout: int = 5):
        super().__init__(driver, _URL, timeout)
        self.__search_textbox = BasePageElement(GoogleLocators.SEARCH_TEXT_BOX,
                                                wait=self._wait)
        self.__search_btn = BasePageElement(GoogleLocators.SEARCH_BTN,
                                            wait=self._wait)
        self.__feeling_lucky_btn = BasePageElement(
            GoogleLocators.FEELING_LUCKY_BTN, wait=self._wait)

    def search(self, value):
        """Simple search."""
        self.__search_textbox.write(value)
        self.__search_btn.click()

    def feeling_lucky(self, value):
        """Feeling lucky search."""
        self.__search_textbox.write(value)
        self.__feeling_lucky_btn.click()
class LoginPage(BasePage):
    """Sauce lab login."""
    def __init__(self, driver: WebDriver, timeout: int = 5):
        super().__init__(driver, _URL, timeout)
        self.__user = BasePageElement(LoginPageLoc.USER, wait=self._wait)
        self.__password = BasePageElement(LoginPageLoc.PASSWORD,
                                          wait=self._wait)
        self.__login = BasePageElement(LoginPageLoc.LOGIN, wait=self._wait)
        self.__error_msg = BasePageElement(LoginPageLoc.ERROR_MSG,
                                           wait=self._wait)

    def login(self, user, password):
        """Login to sauce lab"""
        self.__user.write(user)
        self.__password.write(password)
        self.__login.click()
        return InventoryPage(self._driver, self._timeout)

    def get_error_message(self) -> str:
        """Get login error message
        :return: Error message
        """
        return self.__error_msg.get_text()
class CartPage(BasePage):

    def __init__(self, driver: WebDriver, timeout: int = 5):
        super().__init__(driver, _URL, timeout)
        self.header = Header(self._wait)
        self.products = CartItems(CartLoc.CART_ITEMS, self._wait)
        self.__title = BasePageElement(CartLoc.TITLE, self._wait)
        self.__ctn_shopping = BasePageElement(CartLoc.CTN_SHOPPING, self._wait)
        self.__remove_button = BasePageElement(CartLoc.REMOVE_BUTTON, self._wait)
        self.__checkout_btn = BasePageElement(CartLoc.CHECKOUT_BTN, self._wait)

    def back_shopping(self):
        self.__ctn_shopping.click()

    def checkout(self):
        self.__checkout_btn.click()
        return ContactInfoPage(self._wait._driver, self._wait._timeout)

    def get_title(self) -> str:
        return self.__title.get_text()

    def remove_item(self):
        self.__remove_button.click()
 def __init__(self, wait: WebDriverWait):
     self._wait = wait
     self._link = BasePageElement(HeaderLoc.LINK, wait=wait)
     self._badge = BasePageElement(HeaderLoc.BADGE, wait=wait)
     self._burger_btn = BasePageElement(HeaderLoc.BURGER_BTN, wait=wait)
Exemple #14
0
 def __init__(self, wait: WebDriverWait):
     self._wait = wait
     self._firstname = BasePageElement(ContactInfoLoc.FIRSTNAME, wait=wait)
     self._lastname = BasePageElement(ContactInfoLoc.LASTNAME, wait=wait)
     self._postal_code = BasePageElement(ContactInfoLoc.POSTAL_CODE,
                                         wait=wait)
     self._warning_msg = BasePageElement(ContactInfoLoc.WARNING_MSG,
                                         wait=wait)
     self._cancel_btn = BasePageElement(ContactInfoLoc.CANCEL_BTN,
                                        wait=wait)
     self._continue_btn = BasePageElement(ContactInfoLoc.CONTINUE_BTN,
                                          wait=wait)
Exemple #15
0
class ContactInfo:
    """Represent Contact Info section"""
    def __init__(self, wait: WebDriverWait):
        self._wait = wait
        self._firstname = BasePageElement(ContactInfoLoc.FIRSTNAME, wait=wait)
        self._lastname = BasePageElement(ContactInfoLoc.LASTNAME, wait=wait)
        self._postal_code = BasePageElement(ContactInfoLoc.POSTAL_CODE,
                                            wait=wait)
        self._warning_msg = BasePageElement(ContactInfoLoc.WARNING_MSG,
                                            wait=wait)
        self._cancel_btn = BasePageElement(ContactInfoLoc.CANCEL_BTN,
                                           wait=wait)
        self._continue_btn = BasePageElement(ContactInfoLoc.CONTINUE_BTN,
                                             wait=wait)

    def fill_info(self, firstname="", lastname="", postal_code=""):
        self._firstname.write(firstname)
        self._lastname.write(lastname)
        self._postal_code.write(postal_code)

    def checkout(self):
        self._continue_btn.click()

    def back_to_cart(self):
        self._cancel_btn.click()

    def get_error_msg(self):
        return self._warning_msg.get_text()
Exemple #16
0
 def __init__(self, wait: WebDriverWait):
     self._wait = wait
     self._subtotal = BasePageElement(CheckoutLoc.SUBTOTAL_LABEL, wait=wait)
     self._total = BasePageElement(CheckoutLoc.TOTAL_LABEL, wait=wait)
     self._cancel_btn = BasePageElement(CheckoutLoc.CANCEL_BTN, wait=wait)
     self._finish_btn = BasePageElement(CheckoutLoc.FINISH_BTN, wait=wait)
     self._success_msg = BasePageElement(CheckoutLoc.SUCCESS_MSG, wait=wait)
     self._title = BasePageElement(CheckoutLoc.TITLE_LABEL, wait=wait)