Exemplo n.º 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()
Exemplo n.º 2
0
def test_guest_cant_see_product_in_cart_opened_from_main_page(browser):
    link = "http://selenium1py.pythonanywhere.com/"
    page = MainPage(browser, link)
    page.open()
    page.go_to_cart_page()
    cart_page = CartPage(browser, browser.current_url)
    cart_page.should_see_no_products_in_the_cart()
Exemplo n.º 3
0
def test_guest_cant_see_product_in_cart_opened_from_product_page(browser):
    link = "http://selenium1py.pythonanywhere.com/ru/catalogue/the-shellcoders-handbook_209/"
    page = CartPage(browser, link)
    page.open()
    page.go_to_basket()
    page.should_be_basket_clear()
    page.clear_basket_message()
Exemplo n.º 4
0
 def test_adding_gym_to_cart_and_validate_total_with_tax(self):
     self.logger.info('Starting Add Gym to Cart & Validate Total Test')
     baby_gym_page = PlayGymProduct(self.driver)
     baby_gym_page.go_to_page()
     baby_gym_page.click_add_to_cart()
     cart_page = CartPage(self.driver)
     subtotal = cart_page.get_cart_total()
     self.logger.info('Subtotal was {}'.format(subtotal))
     cart_page.click_checkout_button()
     checkout_page = CheckoutPage(self.driver)
     total = checkout_page.get_cart_total()
     self.logger.info('Total was {}'.format(total))
     checkout_page.enter_email(settings.TEST_EMAIL)
     checkout_page.enter_first_name('B')
     checkout_page.enter_last_name('B')
     checkout_page.enter_address1('Forest Road 1234')
     checkout_page.enter_city('Soda Springs')
     checkout_page.enter_zip('83276')
     checkout_page.enter_phone('1234567890')
     checkout_page.click_continue()
     ShippingModalComponent(self.driver).click_proceed_button()
     shipping_page = ShippingPage(self.driver)
     subtotal = shipping_page.get_cart_subtotal()
     tax_total = shipping_page.get_tax_total()
     # We can implement an Assertion class for better assertions, and take screenshots on fail.
     assert subtotal.replace('$', '') == baby_gym_page.price
     calculated_tax = helper.calculate_tax_total([baby_gym_page.price], settings.IDAHO_TAX_RATE)
     assert tax_total.replace('$', '') == calculated_tax
Exemplo n.º 5
0
def test_guest_cant_see_product_in_cart_opened_from_product_page(browser):
    link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=offer1"
    page = CartPage(browser, link)
    page.open()
    page.go_to_basket()
    page.should_be_basket_clear()
    page.clear_basket_message()
def test_guest_cant_see_product_in_cart_opened_from_main_page(browser):
    link = "http://selenium1py.pythonanywhere.com/"
    page = MainPage(browser, link)
    page.open()
    page.go_to_card_page()
    card_page = CartPage(browser, browser.current_url)
    card_page.sholud_be_empity_basket()
Exemplo n.º 7
0
 def test_go_to_cart_by_add_product(self):
     cart_page = CartPage(self.driver)
     home_page = HomePage(self.driver)
     home_page.click_add_to_cart_button("Beanie")
     home_page.click_view_cart_button("Beanie")
     text_on_checkout_button = cart_page.text_on_checkout_button()
     assert_that(text_on_checkout_button).is_equal_to("Proceed to checkout")
 def test_guest_cant_see_product_in_cart_opened_from_main_page(self, browser):
     link = "http://selenium1py.pythonanywhere.com"
     cart_page = CartPage(browser, link)
     cart_page.open()
     cart_page.go_to_cart()
     cart_page.cart_should_be_empty()
     cart_page.text_should_indicate_that_cart_empty()
Exemplo n.º 9
0
def test_guest_cant_see_product_in_cart_opened_from_main_page(
        browser, link="http://selenium1py.pythonanywhere.com"):
    page = CartPage(browser, link)
    page.open()
    page.go_to_card_page()
    page.should_not_be_disappeared_product()
    page.should_be_success_message()
Exemplo n.º 10
0
def test_guest_cant_see_product_in_cart_opened_from_product_page(browser):
    link = "http://selenium1py.pythonanywhere.com/en-gb/catalogue/the-city-and-the-stars_95/"
    page = ProductPage(browser, link)
    page.open()
    page.go_to_cart_page()
    cart_page = CartPage(browser, browser.current_url)
    cart_page.should_be_empty()
Exemplo n.º 11
0
def test_guest_cant_see_product_in_cart_opened_from_main_page(browser):
    link = "http://selenium1py.pythonanywhere.com"
    page = CartPage(browser, link)
    page.open()
    page.go_to_basket()
    page.should_be_basket_clear()
    page.clear_basket_message()
    def __init__(self):
        self.driver = webdriver.Chrome()
        self.registration_page = RegistrationPage(self.driver)
        self.admin_panel_login_page = AdminPanelLoginPage(self.driver)
        self.customer_list_page = CustomerListPage(self.driver)

        self.product_list_page = ProductListPage(self.driver)
        self.cart_page = CartPage(self.driver)
Exemplo n.º 13
0
 def test_guest_cant_see_product_in_cart_opened_from_product_page(
         self, browser):
     link = "http://selenium1py.pythonanywhere.com/ru/catalogue/coders-at-work_207/?promo=newYear2019"
     cart_page = CartPage(browser, link)
     cart_page.open()
     cart_page.go_to_cart()
     cart_page.cart_should_be_empty()
     cart_page.text_should_indicate_that_cart_empty()
Exemplo n.º 14
0
 def setup(self, driver_setup):
     self.login_page = LoginPage(driver_setup)
     self.results_page = ResultsPage(driver_setup)
     self.product_page = ProductPage(driver_setup)
     self.cart = CartPage(driver_setup)
     self.payment_page = PaymentPage(driver_setup)
     self.delivery_page = DeliveryPage(driver_setup)
     self.product = "jeans"
Exemplo n.º 15
0
 def test_cart_in_header_add_from_recommended_in_cart(self):
     header_cart = HeaderPage(self.driver)
     cart = CartPage(self.driver)
     self.driver.get(TEST_URL + project_page.get('cart'))
     cart.click_first_buy_button_recommended()
     assert cart.check_present_button_in_cart_recommended
     assert '1' == header_cart.text_digit_cart_header
     assert header_cart.text_cart_price in cart.text_first_recommended_price
Exemplo n.º 16
0
def test_guest_cant_see_product_in_cart_opened_from_main_page(browser):
    link = "http://selenium1py.pythonanywhere.com"
    page = MainPage(browser, link)
    page.open()
    page.go_to_basket_page()
    basket_page = CartPage(browser, browser.current_url)
    basket_page.should_not_be_products_in_the_basket()
    basket_page.should_be_text_about_basket_is_empty
Exemplo n.º 17
0
def test_guest_cant_see_product_in_cart_opened_from_product_page(browser):
    link = ProductPageLocators.PRODUCT_PAGE_LINK

    page = MainPage(browser, link)
    page.open()
    page.go_to_basket_page()
    cart_page = CartPage(browser, browser.current_url)
    cart_page.cart_should_be_empty()
def test_guest_cant_see_product_in_basket_opened_from_main_page(browser, user_language):
    link = "http://selenium1py.pythonanywhere.com/"
    page = MainPage(browser, link)
    page.open()
    page.click_cart_button()
    cart_page = CartPage(browser, browser.current_url)
    expected_message = EMPTY_CART_MESSAGES[user_language]
    cart_page.cart_should_be_empty(expected_message)
Exemplo n.º 19
0
def test_guest_cant_see_product_in_cart_opened_from_product_page(
    browser,
    link="http://selenium1py.pythonanywhere.com/catalogue/hacking-exposed-wireless_208/"
):
    page = CartPage(browser, link)
    page.open()
    page.go_to_card_page()
    page.should_not_be_disappeared_product()
    page.should_be_success_message()
Exemplo n.º 20
0
 def test_go_to_cart_by_add_product_soft_assertions(self):
     cart_page = CartPage(self.driver)
     home_page = HomePage(self.driver)
     test_value = -1
     home_page.click_add_to_cart_button("Beanie")
     assert test_value == 1
     home_page.click_view_cart_button("Beanie")
     assert test_value == 2
     text_on_checkout_button = cart_page.text_on_checkout_button()
     assert text_on_checkout_button == "Proceed to checkoutFail"
Exemplo n.º 21
0
def test_guest_cant_see_product_in_cart_opened_from_main_page(browser):
    #Гость открывает главную страницу
    link = MainPageLocators.MAIN_PAGE_LINK
    page = MainPage(browser, link)
    page.open()
    #Переходит в корзину по кнопке в шапке сайта
    page.go_to_cart_page()
    cart_page = CartPage(browser, browser.current_url)
    #Проверяем, что в корзине нет товаров
    cart_page.cart_should_be_empty()
Exemplo n.º 22
0
def test_guest_cant_see_product_in_cart_opened_from_product_page(browser):
    link = ProductPageLocators.PRODUCT_PAGE_LINK
    page = ProductPage(browser, link)
    # Гость открывает страницу товара
    page.open()
    #Переходит в корзину по кнопке в шапке 
    page.go_to_cart_page()
    cart_page = CartPage(browser, browser.current_url)
    #Ожидаем, что в корзине нет товаров
    #Ожидаем, что есть текст о том что корзина пуста 
    cart_page.cart_should_be_empty()
def test_guest_cant_see_product_in_cart_opened_from_main_page(browser):
    link = MainPageLocators.MAIN_PAGE_LINK

    # инициализируем Page Object, передаем в конструктор экземпляр драйвера и url адрес
    page = MainPage(browser, link)
    # открываем нужную страницу
    page.open()
    page.go_to_basket_page()
    cart_page = CartPage(browser, browser.current_url)
    # проверка, что корзина пустая
    cart_page.cart_should_be_empty()
Exemplo n.º 24
0
def test_guest_cant_see_product_in_cart_opened_from_product_page(browser):
    link = ProductPageLocators.PRODUCT_PAGE_LINK

    # инициализируем Page Object, передаем в конструктор экземпляр драйвера и url адрес	
    page = MainPage(browser, link)
    # открываем нужную страницу
    page.open()
    page.go_to_basket_page()
    cart_page = CartPage(browser, browser.current_url)
    # проверка, что в корзине нет товаров и есть сообщение о пустой корзине
    cart_page.cart_should_be_empty()
Exemplo n.º 25
0
class Application:
    def __init__(self, browser):
        if browser == "firefox":
            self.wd = webdriver.Firefox(
                firefox_binary=
                "c:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe")
        elif browser == "chrome":
            self.wd = webdriver.Chrome()
        elif browser == "ie":
            self.wd = webdriver.Ie(capabilities={"requireWindowFocus": True})
        else:
            raise ValueError("Unrecognized browser %s" % browser)
        print(self.wd.capabilities)
        self.wd.implicitly_wait(3)
        self.main_page = MainPage(self.wd)
        self.product_page = ProductPage(self.wd)
        self.cart_page = CartPage(self.wd)

    def is_valid(self):
        try:
            self.wd.current_url
            return True
        except:
            return False

    def destroy(self):
        self.wd.quit()

    def get_products_list(self):
        self.main_page.open()
        products = self.main_page.get_products()
        return products

    def add_random_product_to_cart(self, product_list, q):
        index = randrange(len(product_list))
        self.product_page.open(product_list[index].link)
        old_quantity = self.product_page.cart_quantity.text
        self.product_page.select_size_if_present('Small')
        self.product_page.quantity.click()
        self.product_page.quantity.clear()
        self.product_page.quantity.send_keys(q)
        self.product_page.add_cart_product.click()
        new_quantity = str(int(old_quantity) + q)
        self.product_page.wait_quantity(new_quantity)

    def del_all_products_from_cart(self):
        self.cart_page.open()
        forms = self.cart_page.cart_forms()
        for item in range(forms):
            table = self.cart_page.table
            self.cart_page.remove_cart_item.click()
            self.cart_page.wait_staleness_of_table(table)
        assert self.cart_page.cart_wrapper.text == "There are no items in your cart."
Exemplo n.º 26
0
 def test_cart_delete_item(self):
     header_cart = HeaderPage(self.driver)
     cart = CartPage(self.driver)
     card = CardPage(self.driver)
     module_cart = ModulePage(self.driver)
     self.driver.get(TEST_URL +
                     project_page.get('product_card_with_offers'))
     card.click_button_buy()
     header_cart.click_cart()
     module_cart.click_to_cart()
     # self.close_draggable(self.driver)
     cart.click_button_remove_item()
     assert header_cart.check_cart_without_items
Exemplo n.º 27
0
 def test_product_detail(self):
     '''
     购物车商品,点击跳转到商品详情页
     '''
     print('**在购物车列表,点击第一个商品详情,验证是否跳转到商品详情页面**')
     i = 3
     product_name = CartPage(self.driver).get_product_name_list()
     CartPage(self.driver).click_product_name_i(i)
     sleep(2)
     product_detail_name = ProductPage(self.driver).get_product_name()
     BasePage(self.driver).assert_equal(product_name[i - 1],
                                        product_detail_name)
     ec.url_contains("pages/product/detail?id")
     ec.title_is("商品详情")
def test_guest_cant_see_product_in_cart_opened_from_main_page(browser):
    page = MainPage(browser, MAIN_PAGE_LINK)
    page.open()
    page.go_to_cart_page()
    cart_page = CartPage(browser, browser.current_url)
    cart_page.should_be_cart_url()
    cart_page.cart_is_empty()
    cart_page.should_be_empty_cart_message()
def test_guest_cant_see_product_in_cart_opened_from_main_page(browser):
    page = MainPage(browser, link)
    page.open()
    page.go_to_cart_page()
    cart_page = CartPage(browser, browser.current_url)
    cart_page.should_be_cart_link()
    cart_page.should_be_empty_cart()
    cart_page.should_be_message_empty()
Exemplo n.º 30
0
class CartTest(unittest.TestCase):
    @pytest.fixture(autouse=True)
    def object_setup(self):
        self.front_page = FrontPage(self.driver)
        self.results_page = ResultsPage(self.driver)
        self.cart_page = CartPage(self.driver)
        self.status = Status(self.driver)

    @pytest.fixture()
    def clear_cart_teardown(self):
        yield
        self.results_page.navigate_to_cart_page()
        self.cart_page.remove_all_items_from_cart()

    @pytest.mark.run(order=10)
    @pytest.mark.usefixtures('clear_cart_teardown')
    def test_add_items_to_cart(self):
        self.front_page.navigate_to_front_page()
        self.front_page.search_items('printed')
        self.results_page.add_items_to_cart([1, 3, 5])

        result1 = self.results_page.verify_cart_modal_with_correct_quantity()
        self.status.mark(result1, 'Add multiple products to cart test')

    @pytest.mark.run(order=11)
    def test_items_in_results_page_and_cart_page(self):
        self.front_page.navigate_to_front_page()
        self.front_page.search_items('printed')
        self.results_page.add_items_to_cart([1, 3, 5])

        items_in_results_page = self.results_page.items_in_cart
        items_in_cart_page = self.cart_page.get_items_in_cart(False)

        result = items_in_results_page == items_in_cart_page
        self.status.mark(
            result,
            'Matching items in cart from results page and cart page test')

    @pytest.mark.run(order=12)
    def test_remove_an_item_from_cart(self):
        self.results_page.navigate_to_cart_page()
        self.driver.implicitly_wait(5)
        self.cart_page.remove_an_item_from_cart(2)

        result = self.cart_page.verify_item_is_removed_from_cart()
        self.status.mark(result, 'Remove an item from cart test')

    @pytest.mark.run(order=13)
    def test_remove_all_items_from_cart(self):
        self.cart_page.remove_all_items_from_cart()

        result = self.cart_page.verify_cart_is_empty()
        self.status.mark(result, 'Remove all items from cart test')
    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."
        )