def add_product_in_cart(self, search_category, search_product):
        logger = self.getLogger()

        driver = self.driver
        search_From_Home = HomePage(driver)
        search_From_Home.enter_search_query(search_category)
        search_result_page = search_From_Home.click_search_button()

        products = search_result_page.return_search_products()
        product_name = None
        selected_product = None
        for product in products:
            selected_product = product
            selected_product_name = search_result_page.return_product_name(
                selected_product)
            #print(selected_product_name)
            #print("\n")
            #logger.info(selected_product_name+"\n")
            if search_product in selected_product_name.lower():
                break
        time.sleep(5)

        search_result_page.add_selected_product(selected_product)
        product_name = selected_product_name
        self.added_products.append(product_name)
        return product_name
Ejemplo n.º 2
0
    def test_06_valid_search(self):
        driver = self.driver
        home = HomePage(driver)

        home.click_home()
        search_term = 'Chicken'
        home.enter_search_query(search_term)
        home.press_enter_from_keyboard()
        time.sleep(4)
        try:
            assert search_term in driver.title
            print("Assertion Test Passed")
        except Exception as e:
            print("Assertion Test Failed", format(e))