Пример #1
0
class Application:

    def __init__(self):
        self.driver = webdriver.Chrome()
        self.main_page = MainPage(self.driver)
        self.product_page = ProductPage(self.driver)
        self.cart_page = CartPage(self.driver)

    def open_main_page(self):
        self.main_page.open_p()

    def add_products(self, needed_products):
        while self.main_page.quantity_of_products_in_cart < needed_products:
            self.main_page.goto_product_page()
            self.product_page.add_product_to_cart()
            self.main_page.open_p()

    def goto_cart_page(self):
        self.main_page.goto_cart_page()

    def empty_cart(self):
        if self.cart_page.quantity_of_product_types > 1:
            self.cart_page.product_shotcut.click()
        for i in range(self.cart_page.quantity_of_product_types):
            cells_quantity_before = self.cart_page.cells_quantity
            self.cart_page.remove_product_from_cart()
            self.cart_page.waiting_for_cart_table_update(cells_quantity_before)

    def quit(self):
        self.driver.quit()
Пример #2
0
def test_guest_can_see_success_message_add_product_to_cart(browser):
    link = "http://selenium1py.pythonanywhere.com/catalogue/the-shellcoders-handbook_209/?promo=newYear"
    page = ProductPage(browser, link)
    page.open()
    page.add_product_to_cart()
    page.solve_quiz_and_get_code()
    page.alert_success_addition_present()
Пример #3
0
 def test_user_can_add_product_to_cart(self, browser, link):
     page = ProductPage(browser, link)
     page.open()
     page.add_product_to_cart()
     page.solve_quiz_and_get_code()
     page.check_message_success_added_to_cart()
     page.check_total_price_in_cart()
Пример #4
0
 def test_user_can_add_product_to_basket(self, browser):
     link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/"
     page = ProductPage(browser, link)
     page.open()
     page.add_product_to_cart()
     page.add_product_names_match()
     page.add_product_price_match()
 def test_user_can_add_product_to_basket(self, browser):
     page = ProductPage(browser, link)
     page.open()
     page.add_product_to_cart()
     page.solve_quiz_and_get_code()
     page.should_be_message_product_added_to_cart()
     page.should_be_correct_price_of_cart()
Пример #6
0
def test_guest_can_add_product_to_cart(browser):
    link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/"
    page = ProductPage(browser, link)
    page.open(link)
    page.should_be_add_to_cart_link()
    page.add_product_to_cart()
    page.check_info(link)
def test_guest_can_add_product_to_cart(browser):
    link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/"
    product_page = ProductPage(browser, link)
    product_page.open()
    product_page.add_product_to_cart()
    product_page.product_name_in_alert_is_the_same()
    product_page.product_price_in_alert_is_the_same()
Пример #8
0
def test_message_disappeared_after_adding_product_to_basket(browser):
    link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/"
    page = ProductPage(browser, link)
    page.open(link)
    page.add_product_to_cart()
    time.sleep(1)
    page.should_not_be_success_message_is_disappeared()
Пример #9
0
def test_guest_cant_see_success_message_after_adding_product_to_basket(
        browser):
    link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/"
    page = ProductPage(browser, link)
    page.open(link)
    page.add_product_to_cart()
    page.should_not_be_success_message()
Пример #10
0
 def test_user_can_add_product_to_cart(self, browser, link, setup):
     link = link
     page = ProductPage(browser, link)
     page.open()
     page.add_product_to_cart()
     page.solve_quiz_and_get_code()
     page.should_be_added_to_cart()
Пример #11
0
def test_guest_can_add_product_to_cart(browser):
    link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=offer0"
    page = ProductPage(browser, link)
    page.open()
    page.add_product_to_cart()
    page.solve_quiz_and_get_code()
    page.should_be_added_to_cart()
 def test_user_can_add_product_to_cart(self, browser):
     link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/"
     page = ProductPage(browser, link)
     page.open()
     page.add_product_to_cart()
     page.should_appear_valid_add_message()
     page.should_appear_valid_price_in_cart()
Пример #13
0
def test_message_disappeared_after_adding_product_to_basket(browser):
    link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=newYear2019"
    page = ProductPage(browser, link)
    page.open()
    page.add_product_to_cart()
    page.solve_quiz_and_get_code()
    page.should_disappear_message()
Пример #14
0
 def test_user_can_add_product_to_basket(self, browser):
     link = f'http://selenium1py.pythonanywhere.com/uk/catalogue/coders-at-work_207/?promo=offer1'
     page = ProductPage(browser, link)
     page.open()
     page.add_product_to_cart()
     page.solve_quiz_and_get_code()
     page.verify_book_title_in_success_message()
     page.verify_book_price_in_cart()
Пример #15
0
def test_guest_can_add_product_to_cart(browser):
    link = 'http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=newYear2019'
    page = ProductPage(browser, link)
    page.open()
    page.should_not_be_successful_message()
    page.add_product_to_cart()
    page.should_be_successful_message_with_product_name()
    page.should_be_cart_price_equal_to_product_price()
Пример #16
0
 def test_user_can_add_product_to_basket(self, browser):
     link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=newYear2019"
     page = ProductPage(browser, link)
     page.open()
     page.add_product_to_cart()
     page.solve_quiz_and_get_code()
     page.check_product_name_in_cart()
     page.check_product_price_in_cart()
Пример #17
0
def test_guest_can_add_product_to_basket(browser, number):
    link = f"http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=offer{number}"
    page = ProductPage(browser, link)
    page.open()
    page.add_product_to_cart()
    page.solve_quiz_and_get_code()
    page.add_product_names_match()
    page.add_product_price_match()
Пример #18
0
def test_guest_can_add_product_to_basket(browser, parametrize):
    link = f"http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=offer{parametrize}"
    page = ProductPage(browser, link)
    page.open()
    page.add_product_to_cart()
    page.solve_quiz_and_get_code()
    page.check_product_name_in_cart()
    page.check_product_price_in_cart()
Пример #19
0
def test_user_can_add_product_to_cart(browser, site):
    link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?" + site
    page = ProductPage(browser, link)
    page.open(link)
    page.should_be_add_to_cart_link()
    page.add_product_to_cart()
    page.solve_quiz_and_get_code()
    page.check_info(link)
def test_guest_can_add_product_to_basket(browser):
    link = 'http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=newYear2019'
    page = ProductPage(browser, link)
    page.open()
    page.add_product_to_cart()
    page.solve_quiz_and_get_code()
    page.should_be_message_product_added_to_cart()
    page.should_be_correct_price_of_cart()
Пример #21
0
 def test_user_can_add_product_to_cart(self, browser):
     link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/"
     page = ProductPage(browser, link)
     page.open()
     page.add_product_to_cart()
     page.check_success_add_to_basket_message()
     page.check_product_name_in_success_add_to_basket_message()
     page.check_basket_total_message()
     page.check_price_in_basket_total_message()
Пример #22
0
def test_guest_can_add_product_to_cart(browser):
    link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=offer6"
    page = ProductPage(browser, link)
    page.open()
    page.add_product_to_cart()
    page.solve_quiz_and_get_code()
    time.sleep(3)
    page.should_be_product_name_match()
    page.should_be_price_product_corresponds_to_price_in_basket()
Пример #23
0
def test_guest_can_add_product_to_cart(browser, offer_name):
    link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo={}".format(
        offer_name)
    page = ProductPage(browser, link)
    page.open()
    page.add_product_to_cart()
    page.solve_quiz_and_get_code()
    page.check_success_add_to_basket_message()
    page.check_product_name_in_success_add_to_basket_message()
    page.check_basket_total_message()
    page.check_price_in_basket_total_message()
def test_guest_can_add_product_to_cart(browser):
    link = "http://selenium1py.pythonanywhere.com/catalogue/the-shellcoders-handbook_209/?promo=newYear"
    # link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=newYear2019"
    page = ProductPage(browser, link)
    page.open()
    page.should_be_product_page()
    page.add_product_to_cart()            # жмем кнопку добавить в корзину 
    page.solve_quiz_and_get_code()
    page.should_be_success_message()      # проверяем что есть сообщение с нужным текстом
    page.should_be_valid_cart_name()
    page.should_be_valid_cart_price()
Пример #25
0
def test_guest_can_add_product_to_basket(browser, promo):
    link = f"http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?{promo}"
    page = ProductPage(browser, link)
    page.open()
    page.add_product_to_cart()
    time.sleep(5)
    page.item_name_should_matched()
    time.sleep(5)
    page.item_price_should_matched()
    time.sleep(5)
    page.success_message_should_be()
    def test_add_cart_items(self):

        main_page = MainPage(self.driver)
        product_page = None

        for _ in xrange(NUMBER_OF_PRODUCTS):
            main_page.open()
            main_page.first_product.click()
            product_page = ProductPage(self.driver)
            product_page.add_product_to_cart()

        product_page.checkout()
        cart_page = CartPage(self.driver)
        cart_page.wait_for_confirm_btn_present()
        cart_page.remove_all_items()
        cart_page.wait_for_confirm_btn_disappear()
        self.assertEqual(
            cart_page.get_checkout_text_present(),
            "There are no items in your cart."
        )
Пример #27
0
class Application:
    def __init__(self):
        self.driver = webdriver.Chrome()
        self.start_page = StartPage(self.driver)
        self.product_page = ProductPage(self.driver)
        self.base_page = BasePage(self.driver)
        self.cart_page = CartPage(self.driver)

    def quit(self):
        self.driver.quit()

    def add_product_to_cart(self):
        self.start_page.open()
        self.start_page.open_first_product_page()
        self.product_page.add_product_to_cart()
        # self.base_page.go_home()

    def delete_product_from_cart(self):
        self.cart_page.open()
        self.cart_page.remove_product_from_cart()
Пример #28
0
class Application():

    def __init__(self):
        self.driver = webdriver.Chrome()
        self.main_page = MainPage(self.driver)
        self.cart_page = CartPage(self.driver)
        self.product_page = ProductPage(self.driver)

    def quit(self):
        self.driver.quit()

    def add_products_to_cart(self, quantity_product):
        self.main_page.open()
        for i in range(quantity_product):
            self.main_page.open_product_page()
            self.product_page.add_product_to_cart()
            self.product_page.back_to_main_page()

    def delete_all_products_at_cart(self):
        self.main_page.open_cart()
        self.cart_page.del_all_product_at_cart()
Пример #29
0
def test_guest_can_add_product_to_cart(browser, link):
    product_page = ProductPage(browser, link)
    product_page.open()
    product_page.add_product_to_cart()
    solve_quiz_and_get_code(product_page)
    product_page.is_product_added_to_cart()
Пример #30
0
def test_message_disappeared_after_adding_product_to_cart(browser):
    product_link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=newYear2019"
    page = ProductPage(browser, product_link)
    page.open()
    page.add_product_to_cart()
    page.should_be_disappeared_success_message()
Пример #31
0
def test_guest_can_add_product_to_cart(browser):
    page = ProductPage(browser, coders_at_work_207_product_page)
    page.open()
    page.add_product_to_cart()
    page.should_be_product_added_to_cart_message()
    page.should_be_basket_price_message()