示例#1
0
    def test_adding_item_to_shopping_cart(self):
        product_xpath = '//*[@id="js-product-list"]/div[1]/article[3]/div/a/img'
        add_button_xpath = '//*[@id="add-to-cart-or-refresh"]/div[2]/div/div[2]/button'
        expected_text = '\ue876Product successfully added to your shopping cart'
        # confirmation_modal_title_xpath = '//*[@id="lol_nie_ma"]'
        confirmation_modal_title_xpath = '//*[@id="myModalLabel"]'

        driver = self.ef_driver
        time.sleep(2)
        driver.get(self.art_product_url)
        time.sleep(2)

        product_element = driver.find_element_by_xpath(product_xpath)
        product_element.click()
        time.sleep(2)

        add_button_element = driver.find_element_by_xpath(add_button_xpath)
        add_button_element.click()
        time.sleep(2)
        # confirmation_modal_element = WebDriverWait(driver, 10).until(
        #   EC.visibility_of_element_located((By.XPATH, confirmation_modal_title_xpath)),
        #   f"Element for xpath: '{confirmation_modal_title_xpath}' and url: {driver.current_url} not found")

        confirmation_modal_element = oh.visibility_of_element_wait(
            driver, confirmation_modal_title_xpath, 1)
        self.assertEqual(expected_text, confirmation_modal_element.text)
    def test_adding_product_to_shopping_cart(self):
        driver = self.driver
        driver.get(self.art_page_url)

        product_xpath = '//*[contains(text(),"Hummingbird - Vector graphics")]'
        add_to_shopping_cart_button_xpath = '//button[@class="btn btn-primary add-to-cart"]'
        confirmation_modal_title_xpath = '//*[@class="modal-title h6 text-sm-center"]'
        expected_confirmation_modal_text = '\ue876Product successfully added to your shopping cart'

        driver.find_element_by_xpath(product_xpath).click()
        driver.find_element_by_xpath(add_to_shopping_cart_button_xpath).click()

        confirmation_modal_element = oh.visibility_of_element_wait(driver, confirmation_modal_title_xpath)
        self.assertEqual(expected_confirmation_modal_text, confirmation_modal_element.text)
示例#3
0
 def test_adding_item_to_shopping_cart(self):
     expected_confirmation_modal_text = '\ue876Product successfully added to your shopping cart'
     item_xpath = '//*[@alt="Mountain fox - Vector graphics"]'
     shopping_cart_button_xpath = '//*[@class="btn btn-primary add-to-cart"]'
     confirmation_modal_title_xpath = '//*[@id="myModalLabel"]'
     driver = self.ef_driver
     driver.get(self.subpage_art_url)
     item_element = driver.find_element_by_xpath(item_xpath)
     item_element.click()
     shopping_cart_button_element = driver.find_element_by_xpath(
         shopping_cart_button_xpath)
     shopping_cart_button_element.click()
     confirmation_modal_element = oh.visibility_of_element_wait(
         driver, confirmation_modal_title_xpath)
     self.assertEqual(expected_confirmation_modal_text,
                      confirmation_modal_element.text)
 def test_add_mountain_fox(self):
     xpath_Mountain_fox = '//*[@ src = "https://autodemo.testoneo.com/15-home_default/mountain-fox-vector-graphics.jpg"]'
     xpath_Mountain_fox_adding_to_cart = '//* [@class = "btn btn-primary add-to-cart"]'
     xpath_modal_element = '//*[@id = "myModalLabel"]'
     expected_modal_element_text = 'Product successfully added to your shopping cart'
     driver = self.ef_driver
     driver.get(self.art_url)
     mountain_fox_element = driver.find_element_by_xpath(xpath_Mountain_fox)
     mountain_fox_element.click()
     add_button_element = driver.find_element_by_xpath(
         xpath_Mountain_fox_adding_to_cart)
     add_button_element.click()
     confirmation_modal_element = oh.visibility_of_element_wait(
         driver, xpath_modal_element)
     self.assertIn(
         expected_modal_element_text, confirmation_modal_element.text,
         f'Expected text differ than acctual for page {driver.current_url} and in {confirmation_modal_element.text}'
     )
示例#5
0
    def test_add_to_cart(self):
        confirmation_modal_title_xpath = '//*[@id="myModalLabel"]'
        expected_confirmation_text = 'Product successfully added to your shopping cart'
        add_to_cart_button_xpath = '//*[@class="btn btn-primary add-to-cart"]'
        driver = self.ef_driver
        driver.get(self.product_url)
        add_to_cart_button = driver.find_element_by_xpath(
            add_to_cart_button_xpath)
        add_to_cart_button.click()

        # Waiting for the element using custom function
        # confirmation_modal_elements = oh.wait_for_elements(driver, confirmation_modal_title_xpath,
        # max_seconds_to_wait=10, number_of_expected_elements=1)
        # confirmation_modal_element = confirmation_modal_elements[0]

        confirmation_modal_element = oh.visibility_of_element_wait(
            driver, confirmation_modal_title_xpath)
        self.assertEqual(
            expected_confirmation_text, confirmation_modal_element.text[1:],
            f'Expected text differ from actual on page: {driver.current_url}')