コード例 #1
0
 def setUp(self):
     super(SearchProductTest, self).setUp()
     self.home_page = HomePage(self.driver)
     self.product_page = ProductPage(self.driver)
     self.shopping_cart_page = ShoppingCartPage(self.driver)
     self.dresses_page = DressesPage(self.driver)
     self.data = data_provider.test_data_provider()
コード例 #2
0
class SearchProductTest(BaseSetup, unittest.TestCase):
    def setUp(self):
        super(SearchProductTest, self).setUp()
        self.home_page = HomePage(self.driver)
        self.product_page = ProductPage(self.driver)
        self.shopping_cart_page = ShoppingCartPage(self.driver)
        self.dresses_page = DressesPage(self.driver)
        self.data = data_provider.test_data_provider()

    def test_check_if_product_was_added_th_the_cart(self):
        self.home_page.search_product(self.data.get("search_item"))
        self.home_page.search_button()
        self.product_page.select_product()
        self.product_page.continue_shopping_button()
        self.home_page.cart_button()
        self.shopping_cart_page.cart_products("blouseItemInTheCartByLinkText")
        self.assertEqual(
            self.shopping_cart_page.cart_products(
                "blouseItemInTheCartByLinkText")[-1].text, "Blouse")

    def test_add_all_summer_dresses_to_the_cart(self):
        self.home_page.dresses_button_click_on()
        self.dresses_page.summer_dresses_image_click_on()
        self.dresses_page.add_to_the_cart_all_products_in_the_category()
        self.home_page.cart_button()
        self.assertEqual(
            self.shopping_cart_page.cart_products(
                "pinnedSummerDressByLinkText")[0].text, "Printed Summer Dress")
        self.assertEqual(
            self.shopping_cart_page.cart_products(
                "pinnedSummerDressByLinkText")[1].text, "Printed Summer Dress")

    def tearDown(self):
        super(SearchProductTest, self).tearDown()
コード例 #3
0
 def __init__(self):
     self.driver = webdriver.Chrome()
     self.driver.implicitly_wait(2)
     self.registration_page = RegistrationPage(self.driver)
     self.admin_panel_login_page = AdminPanelLoginPage(self.driver)
     self.customer_list_page = CustomerListPage(self.driver)
     self.store_main_page = StoreMainPage(self.driver)
     self.shopping_cart_page = ShoppingCartPage(self.driver)
コード例 #4
0
class Application:
    def __init__(self):
        self.driver = webdriver.Chrome()
        self.products_shop_page = ProductsShopPage(self.driver)
        self.product_details_page = ProductsDetailsPage(self.driver)
        self.shopping_cart_page = ShoppingCartPage(self.driver)

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

    def add_products_to_card(self, products):
        for i in range(len(products)):
            self.products_shop_page.open_products_page()
            self.products_shop_page.find_product_page(products[i].name)
            self.product_details_page.add_product_to_cart(products[i])

    def clear_shopping_cart(self):
        self.shopping_cart_page.open()
        self.shopping_cart_page.clear_shopping_cart()
コード例 #5
0
    def test_placing_order(self, product_name, customer_contact):
        home_page = HomePage(self.driver)
        home_page.visit_by_URL()
        home_page.search_for_item_with_filter(term=product_name,
                                              buy_it_now=True,
                                              free_shipping=False)

        search_results_page = SearchResultsPage(self.driver)
        found_items = search_results_page.get_list_of_found_items()
        search_results_page.visit_random_item(items=found_items)

        product_page = ProductPage(self.driver)
        product_page.wait_until_page_is_visible()
        product_page.add_to_cart()
        product_page.view_cart()

        shopping_cart_page = ShoppingCartPage(self.driver)
        shopping_cart_page.visit_checkout()

        checkout_page = CheckoutPage(self.driver)
        checkout_page.enter_as_guest()
        checkout_page.provide_contact_details(*customer_contact)
コード例 #6
0
 def setUpClass(cls):
     cls.driver = base_driver()
     cls.baseaction = BaseAction(cls.driver)
     cls.wx_page = WxPage(cls.driver)
     cls.home_page = HomePage(cls.driver)
     cls.commodity_details_page = CommodityDetailsPage(cls.driver)
     cls.my_page = MyPage(cls.driver)
     cls.navigation_bar_page = NavigationBarPage(cls.driver)
     cls.confirm_order_page = ConfirmOrderPage(cls.driver)
     cls.pay_complete_page = PayCompletePage(cls.driver)
     cls.my_order_page = MyOrderPage(cls.driver)
     cls.shopping_cart_page = ShoppingCartPage(cls.driver)
     cls.order_details_page = OrderDetailsPage(cls.driver)
     print("开始测试")
コード例 #7
0
def before_all(context: Context):
    # setup global variables
    setup = context.config.userdata
    context.driver = get_driver(browser=setup["browser"],
                                resolution=setup["resolution"])
    # setup page_objects
    context.main_page = MainPage(context=context)
    context.search_page = SearchPage(context=context)
    context.authentication_page = AuthenticationPage(context=context)
    context.registration_page = RegistrationPage(context=context)
    context.shopping_cart_page = ShoppingCartPage(context=context)
    # open application under test
    context.search_page.go_to_url(
        url="http://automationpractice.com/index.php")
コード例 #8
0
class Application:

    def __init__(self):
        self.driver = webdriver.Chrome()
        self.driver.implicitly_wait(2)
        self.registration_page = RegistrationPage(self.driver)
        self.admin_panel_login_page = AdminPanelLoginPage(self.driver)
        self.customer_list_page = CustomerListPage(self.driver)
        self.store_main_page = StoreMainPage(self.driver)
        self.shopping_cart_page = ShoppingCartPage(self.driver)

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

    def register_new_customer(self, customer):
        self.registration_page.open()
        self.registration_page.firstname_input.send_keys(customer.firstname)
        self.registration_page.lastname_input.send_keys(customer.lastname)
        self.registration_page.address1_input.send_keys(customer.address)
        self.registration_page.postcode_input.send_keys(customer.postcode)
        self.registration_page.city_input.send_keys(customer.city)
        self.registration_page.select_country(customer.country)
        self.registration_page.select_zone(customer.zone)
        self.registration_page.email_input.send_keys(customer.email)
        self.registration_page.phone_input.send_keys(customer.phone)
        self.registration_page.password_input.send_keys(customer.password)
        self.registration_page.confirmed_password_input.send_keys(customer.password)
        self.registration_page.create_account_button.click()

    def add_items_in_shopping_cart(self, quantity=1):
        self.store_main_page.open()
        self.store_main_page.open_ducks_list.click()
        for i in range(quantity):
            random.choice(self.store_main_page.duck_list).click()
            self.store_main_page.open_duck_item.click()
            try:
                self.store_main_page.select_size("Medium")
            except:
                pass
            finally:
                self.store_main_page.add_duck_in_shopping_cart.click()
                self.store_main_page.wait_add_item_in_cart(i)

    def quantity_item_in_shopping_cart_on_main_page(self):
        return self.store_main_page.quantity_item_in_cart

    def remove_all_items_in_shopping_cart(self):
        self.shopping_cart_page.open()
        items = self.shopping_cart_page.item_list
        for i in range(len(items)):
            i_price = self.shopping_cart_page.item_price.text
            subtotal_price = self.shopping_cart_page.subtotal_price_of_all_items.text
            self.shopping_cart_page.remove_item.click()
            if i != len(items) - 1:
                self.shopping_cart_page.change_subtotal_price(subtotal_price, i_price)
            else:
                break

    def text_when_shopping_cart_list_is_empty(self):
        return self.shopping_cart_page.text_when_list_is_empty

    def get_customer_ids(self):
        if self.admin_panel_login_page.open().is_on_this_page():
            self.admin_panel_login_page.enter_username("admin").enter_password("admin").submit_login()
        return self.customer_list_page.open().get_customer_ids()
コード例 #9
0
class TestShoppingCart():
    @pytest.fixture(autouse=True)
    def object_setup(self):
        self.dp = DressesPage(self.driver)
        self.cdp = ChiffonDressPage(self.driver)
        self.scp = ShoppingCartPage(self.driver)
        self.scp_session = ShoppingCartPage(self.driver)
        self.ast = AssertStatus()

    def test_chiffon_dress_shopping_cart_details(self):
        result_1 = self.dp.navigate_to_dresses_page()
        self.ast.collect_result(result_1, "Dresses Page Title Verification")

        self.dp.click_chiffon_dress_link()
        result_2 = self.cdp.verify_chiffon_dress_page_title()
        self.ast.collect_result(result_2,
                                "Chiffon Dress Page Title Verification")

        self.cdp.order_chiffon_dress()
        self.cdp.set_chiffon_dress_image_attributes()
        self.cdp.click_chiffon_dress_popup_cart_checkout_button()
        result_3 = self.scp.verify_shopping_cart_page_title()
        self.ast.collect_result(result_3,
                                "Shopping Cart Page Title Verification")

        result_4 = self.scp.verify_chiffon_dress_product_image()
        self.ast.collect_result(result_4, "Chiffon Dress Image Verification")

        result_5 = self.scp.verify_chiffon_dress_product_title()
        self.ast.collect_result(result_5,
                                "Chiffon Dress Product Title Verification")

        result_6 = self.scp.verify_chiffon_dress_product_model()
        self.ast.collect_result(result_6,
                                "Chiffon Dress Product Model Verification")

        result_7 = self.scp.verify_chiffon_dress_product_attributes()
        self.ast.collect_result(
            result_7, "Chiffon Dress Product Attributes Verification")

        result_8 = self.scp.verify_chiffon_dress_discount_price()
        self.ast.collect_result(result_8,
                                "Chiffon Dress Discount Price Verification")

        self.scp.click_delete_chiffon_dress()
        result_9 = self.scp.verify_empty_shopping_cart()
        self.ast.determine_result(result_9, "Empty Shopping Cart Verification",
                                  "test_chiffon_dress_shopping_cart_details")

    @pytest.mark.parametrize(
        "update_quantity, quantity, price, products_total, "
        "shipping, subtotal, tax, total, delete_quantity",
        get_csv_data("product_totals_test_data.csv"))
    def test_chiffon_dress_shopping_cart_product_totals(
            self, update_quantity, quantity, price, products_total, shipping,
            subtotal, tax, total, delete_quantity):
        result_1 = self.dp.navigate_to_dresses_page()
        self.ast.collect_result(result_1, "Dresses Page Title Verification")

        self.dp.click_chiffon_dress_link()
        result_2 = self.cdp.verify_chiffon_dress_page_title()
        self.ast.collect_result(result_2,
                                "Chiffon Dress Page Title Verification")

        self.cdp.order_chiffon_dress()
        self.cdp.click_chiffon_dress_popup_cart_checkout_button()
        result_3 = self.scp.verify_shopping_cart_page_title()
        self.ast.collect_result(result_3,
                                "Shopping Cart Page Title Verification")

        self.scp.enter_chiffon_dress_quantity(update_quantity)
        result_9 = self.scp.verify_chiffon_dress_quantity(quantity)
        self.ast.collect_result(result_9,
                                "Chiffon Dress Quantity Verification")

        result_10 = self.scp.verify_chiffon_dress_total_product_price(price)
        self.ast.collect_result(result_10,
                                "Chiffon Dress Product Price Verification")

        result_11 = (
            self.scp.verify_shopping_cart_products_total(products_total))
        self.ast.collect_result(result_11,
                                "Shopping Cart Products Total Verification")

        result_12 = self.scp.verify_shopping_cart_shipping_total(shipping)
        self.ast.collect_result(result_12,
                                "Shopping Cart Shipping Total Verification")

        result_13 = self.scp.verify_shopping_cart_subtotal(subtotal)
        self.ast.collect_result(result_13,
                                "Shopping Cart Subtotal Verification")

        result_14 = self.scp.verify_shopping_cart_tax_total(tax)
        self.ast.collect_result(result_14,
                                "Shopping Cart Tax Total Verification")

        result_15 = self.scp.verify_shopping_cart_price_total(total)
        self.ast.collect_result(result_15,
                                "Shopping Cart Price Total Verification")

        self.scp.enter_chiffon_dress_quantity(delete_quantity)
        result_16 = self.scp.verify_empty_shopping_cart()
        self.ast.determine_result(
            result_16, "Empty Shopping Cart Verification",
            "test_chiffon_dress_shopping_cart_product_totals")

    def test_loading_chiffon_dress_shopping_cart_session(self):
        result_1 = self.dp.navigate_to_dresses_page()
        self.ast.collect_result(result_1, "Dresses Page Title Verification")

        self.dp.click_chiffon_dress_link()
        result_2 = self.cdp.verify_chiffon_dress_page_title()
        self.ast.collect_result(result_2,
                                "Chiffon Dress Page Title Verification")

        self.cdp.order_chiffon_dress()
        self.cdp.click_chiffon_dress_popup_cart_checkout_button()
        result_3 = self.scp.verify_shopping_cart_page_title()
        self.ast.collect_result(result_3,
                                "Shopping Cart Page Title Verification")

        self.scp_session.load_shopping_cart_session()
        result_4 = self.scp_session.verify_chiffon_dress_product_title()
        self.ast.collect_result(result_4,
                                "Chiffon Dress Product Title Verification")

        self.scp_session.click_delete_chiffon_dress()
        result_5 = self.scp_session.verify_empty_shopping_cart()
        self.ast.collect_result(result_5, "Empty Shopping Cart Verification")

        self.scp_session.quit_shopping_cart_page()
        self.scp.refresh_shopping_cart_page()
        result_6 = self.scp.verify_empty_shopping_cart()
        self.ast.determine_result(
            result_6, "Empty Shopping Cart Verification",
            "test_loading_chiffon_dress_shopping_cart_session")
コード例 #10
0
 def object_setup(self):
     self.dp = DressesPage(self.driver)
     self.cdp = ChiffonDressPage(self.driver)
     self.scp = ShoppingCartPage(self.driver)
     self.scp_session = ShoppingCartPage(self.driver)
     self.ast = AssertStatus()
コード例 #11
0
ファイル: products_page.py プロジェクト: forhadh030/selenium
 def add_item_to_cart(self):
     self.add_to_cart_btn()[0].click()
     self.shopping_cart_icon().click()
     return ShoppingCartPage(self.driver)
コード例 #12
0
 def __init__(self):
     self.driver = webdriver.Chrome()
     self.products_shop_page = ProductsShopPage(self.driver)
     self.product_details_page = ProductsDetailsPage(self.driver)
     self.shopping_cart_page = ShoppingCartPage(self.driver)