Exemplo n.º 1
0
class ClickItemsCSVDataTests(unittest.TestCase):
    @pytest.fixture(autouse=True)
    def objectSetup(self, oneTimeSetUp):
        self.items = ClickItems(self.driver)
        self.ts = TestStatus(self.driver)
        self.nav = NavigationPage(self.driver)

    def setUp(self):
        """
        after every test -> the web page will be navigate to practice page -> main page .
        :return:
        """
        self.nav.navigateToPracticePage()

    @pytest.mark.run(order=1)
    @data(*getCSVData(
        "C:\\Users\\vadim\PycharmProjects\\automationPracticeStore.com\\datafile.csv"
    ))
    @unpack
    def test_click_on_item(self, item, amount):
        """
        using ddt and get the items from 'datafile.csv' file .
        :param item: the item the automation will be checking .
        :param amount: amount of time this item will be added to the cart .
        :return:
        """
        self.items.click_on_item(item=item)
        self.items.add_to_cart(amount=amount)
        result1 = self.items.verify_item_added_successfully(amount=amount)
        self.ts.mark(result1, "######### ITEM DID NOT ADDED SUCCESSFULLY .")
        self.ts.markFinal("##### ADD ITEM AND TOTAL PRICE TEST CHECK")
Exemplo n.º 2
0
class ProductButtonCSVDataTests(unittest.TestCase):
    @pytest.fixture(autouse=True)
    def objectSetup(self, oneTimeSetUp):
        self.product = ProductButtonsCheck(self.driver)
        self.ts = TestStatus(self.driver)
        self.nav = NavigationPage(self.driver)

    def setUp(self):
        """
        naviage to practice page after every test .
        :return:
        """
        self.nav.navigateToPracticePage()

    @pytest.mark.run(order=1)
    @data(*getCSVData(
        "C:\\Users\\vadim\PycharmProjects\\automationPracticeStore.com\\option.csv"
    ))
    @unpack
    def test_product_tag_sofa(self, option):
        self.product.check_tag(option)
        result = self.product.check_elements_text(option)
        self.ts.mark(
            result,
            "######### PRODUCT {} TEST DID NOT PASSED .".format(option))
        self.ts.markFinal("######## PRODUCT {} TEST .".format(option))
Exemplo n.º 3
0
def one_time_setup(request, browser):
    print("Running one time setup")
    wds = WebDriverSetup(browser)
    driver = wds.get_webdriver_instance()
    lp = LoginPage(driver)
    nav = NavigationPage(driver)
    nav.click_login_link()
    lp.login("*****@*****.**", "123456")

    if request.cls is not None:
        request.cls.driver = driver
    yield driver
    driver.quit()
    print("Running one time teardown")
Exemplo n.º 4
0
class ProductCategoriesCSVDataTests(unittest.TestCase):
    @pytest.fixture(autouse=True)
    def objectSetup(self, oneTimeSetUp):
        self.category = ProductCategoriesCheck(self.driver)
        self.ts = TestStatus(self.driver)
        self.nav = NavigationPage(self.driver)

    def setUp(self):
        """
        navigate to categories page after every test in this file .
        :return:
        """
        self.nav.navigateToProductCategoriesPage()

    @pytest.mark.run(order=1)
    @data(*getCSVData(
        "C:\\Users\\vadim\PycharmProjects\\automationPracticeStore.com\\categories.csv"
    ))
    @unpack
    def test_product_categories(self, category, number):
        """
        this test will check every category from 'categories.csv' file according the explanations .
        :param category: the category the automation checks .
        :param number: variable to locate the right category using xpath .
        :return:
        """
        # clicks on a 'category' .
        self.category.click_on_category(category=category)
        # get the text (number) located on the right of the 'category' text .
        items_amount = self.category.check_displayed_item_for_category(
            number=number)
        # after automation clicks on category -> get the number of items displayed for this category .
        displayed_items_amount = self.category.check_displayed_items_amount()
        # check if the numbers are equal .
        result = self.category.check_amount(
            items_amount=items_amount,
            displayed_items_amount=displayed_items_amount)
        self.ts.mark(result, "######### INVALID amount of items .")
        # then checks the text under every item displayed -> check if this item should be displayed .
        result = self.category.check_items_displayed(category=category)
        self.ts.mark(result, "######### INVALID item displayed .")
        self.ts.markFinal("######## ITEMS AMOUNT TEST .")
Exemplo n.º 5
0
class SearchBoxCSVDataTests(unittest.TestCase):
    @pytest.fixture(autouse=True)
    def objectSetup(self, oneTimeSetUp):
        self.search = SearchBox(self.driver)
        self.ts = TestStatus(self.driver)
        self.nav = NavigationPage(self.driver)

    def setUp(self):
        self.nav.navigateToPracticePage()

    @pytest.mark.run(order=1)
    @data(*getCSVData(
        "C:\\Users\\vadim\PycharmProjects\\automationPracticeStore.com\\itemsToSearch.csv"
    ))
    @unpack
    def test_search_box(self, item):
        self.search.search_item(item=item)
        result = self.search.check_search(item=item)
        self.ts.mark(result,
                     "######### ITEM IS ON THE LIST AND LOCATOR FOUND .")
        self.ts.markFinal("######## SEARCH BOX TEST PASSED .")
class DressesPage(BasePage):
    """
    Page class representing the dresses page

    Contains methods that interact with web elements
    located on the dresses page

    Arguments:
        driver(obj): Webdriver instance

    Attributes:
        log(obj): Logger instance
        driver(obj): Webdriver instance
        nav(obj): NavigationPage instance
    """

    log = custom_logger(logging.INFO)

    # locators
    _store_menu = '.lnk_view'
    _chiffon_dress_link = "li:nth-child(5) h5:nth-child(1) > a.product-name"

    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver
        self.nav = NavigationPage(driver)

    def verify_dresses_page_title(self):
        return self.wait_for_title("Dresses - My Store")

    def navigate_to_dresses_page(self):
        self.nav.click_clothes_menu_link("dresses")
        return self.verify_dresses_page_title()

    def click_chiffon_dress_link(self):
        element = self.wait_for_element_to_be_clickable(
            self._chiffon_dress_link, "css")
        self.click_element(element=element)
Exemplo n.º 7
0
 def objectSetup(self, oneTimeSetUp):
     self.items = ClickItems(self.driver)
     self.ts = TestStatus(self.driver)
     self.nav = NavigationPage(self.driver)
class LoginPage(BasePage):
    """
    Page class representing the login page

    Contains methods that interact with web elements
    located on the login page

    Arguments:
        driver(obj): Webdriver instance

    Attributes:
        log(obj): Logger instance
        driver(obj): Webdriver instance
        nav(obj): NavigationPage instance
    """

    log = custom_logger(logging.INFO)

    def __init__(self, driver):
        super().__init__(driver)
        self.nav = NavigationPage(driver)

    # locators
    _email_input = "email"
    _password_input = "passwd"
    _login_button = "SubmitLogin"
    _login_error_message = "div.alert.alert-danger ol"
    _logged_in = "a.account"
    _forgotten_password_link = "p.lost_password.form-group > a"
    _nav_bar = "nav div a"

    def verify_login_page_title(self):
        return self.verify_page_title("Login - My Store")

    def enter_login_email_input(self, username):
        self.sending_keys(username, self._email_input)

    def enter_login_password_input(self, password):
        self.sending_keys(password, self._password_input)

    def click_login_button(self):
        self.click_element(self._login_button)

    def login(self, username, password):
        self.enter_login_email_input(username)
        self.enter_login_password_input(password)
        self.click_login_button()

    def verify_valid_login(self):
        return self.is_element_present(self._logged_in, "css")

    def verify_invalid_password_error_message(self):
        return self.is_text_present(self._login_error_message, "css",
                                    "Authentication failed.")

    def verify_invalid_login_error_message(self, *args):
        return self.is_text_present(self._login_error_message,
                                    "css",
                                    *args,
                                    selector="li")

    def remain_logged_out(self):
        self.click_list_element_containing_text(self._nav_bar, "css",
                                                "Sign out")

    def navigate_to_login_page(self):
        self.remain_logged_out()
        self.nav.click_login_link()
        return self.verify_login_page_title()

    def click_forgotten_password_link(self):
        self.click_element(self._forgotten_password_link, "css")

    def navigate_to_forgotten_password_page(self):
        self.remain_logged_out()
        self.nav.click_login_link()
        self.click_forgotten_password_link()
 def __init__(self, driver):
     super().__init__(driver)
     self.nav = NavigationPage(driver)
Exemplo n.º 10
0
 def __init__(self, driver):
     super().__init__(driver)
     self.driver = driver
     self.nav = NavigationPage(driver)
     self.action = ActionChains(driver)
     self.util = Util()
Exemplo n.º 11
0
 def objectSetup(self, oneTimeSetUp):
     self.product = ProductButtonsCheck(self.driver)
     self.ts = TestStatus(self.driver)
     self.nav = NavigationPage(self.driver)
Exemplo n.º 12
0
 def objectSetup(self, oneTimeSetUp):
     self.category = ProductCategoriesCheck(self.driver)
     self.ts = TestStatus(self.driver)
     self.nav = NavigationPage(self.driver)
Exemplo n.º 13
0
 def objectSetup(self, oneTimeSetUp):
     self.search = SearchBox(self.driver)
     self.ts = TestStatus(self.driver)
     self.nav = NavigationPage(self.driver)