def test_information_input(driver, browser, mode, device, username, password): """Test the name and postal code input boxes on the checkout page.""" # Proceed to checkout page login_page = LoginPage(driver) login_page.perform_complete_login(username, password) product_page = ProductListPage(driver) product_page.click_cart() cart_page = CartPage(driver) cart_page.click_checkout() # Try to continue without filling out information checkout_page = CheckoutPage(driver) checkout_page.click_continue() assert checkout_page.is_error_message_present() # Input information first_name = "Testy" last_name = "McTest" postal_code = "08221" checkout_page.input_first_name(first_name) checkout_page.input_last_name(last_name) checkout_page.input_postal_code(postal_code) checkout_page.input_payment_details() # Check data was successfully inserted and we can continue assert checkout_page.get_first_name() == first_name assert checkout_page.get_last_name() == last_name assert checkout_page.get_postal_code() == postal_code checkout_page.click_continue() overview_page = OverviewPage(driver) assert overview_page.get_subheader() == "Checkout: Overview"
def test_checkout_all_items(driver, browser, mode, device, username, password): """Test the checkout process with all items on the PLP.""" login_page = LoginPage(driver) login_page.perform_complete_login(username, password) product_list_page = ProductListPage(driver) add_to_cart_buttons = product_list_page.get_add_to_cart_buttons() num_items_in_cart = 0 assert product_list_page.get_number_cart_items() == num_items_in_cart, \ "An unexpected item has been found in the cart." # Add products, check mini cart total. for button in add_to_cart_buttons: button.click() num_items_in_cart += 1 assert num_items_in_cart == product_list_page.get_number_cart_items(), \ "An unexpected item has been found in the cart." time.sleep(1) assert button.text == REMOVE assert product_list_page.get_number_cart_items() == len(add_to_cart_buttons), \ "Unexpected number of cart items" product_list_page.click_cart() # Continue to the checkout page from the cart page. cart_page = CartPage(driver) cart_total = cart_page.get_sum_prices() cart_page.click_checkout() # Attempt to checkout without entering a name and postal code. checkout_page = CheckoutPage(driver) checkout_page.click_continue() assert checkout_page.is_error_message_present() # Checkout with valid information first_name = "Testy" last_name = "McTest" postal_code = "08221" checkout_page.input_first_name(first_name) checkout_page.input_last_name(last_name) checkout_page.input_postal_code(postal_code) checkout_page.input_payment_details() assert checkout_page.get_first_name() == first_name assert checkout_page.get_last_name() == last_name assert checkout_page.get_postal_code() == postal_code checkout_page.click_continue() # Check the overview page before completing the order. overview_page = OverviewPage(driver) assert overview_page.get_subheader() == "Checkout: Overview" assert cart_total == overview_page.get_subtotal() overview_page.click_finish() # Check the order confirmation page. order_confirmation_page = OrderConfirmationPage(driver) assert order_confirmation_page.get_subheader() == "Finish" assert product_list_page.get_number_cart_items( ) == 0, "Unexpected item found in cart."
def test_remove_from_cart(driver, browser, mode, device, username, password): """Test the cart page's remove from cart button.""" login_page = LoginPage(driver) login_page.perform_complete_login(username, password) product_page = ProductListPage(driver) product_page.add_all_to_cart() product_page.click_cart() cart_page = CartPage(driver) cart_page.remove_all_from_cart()
def test_checkout_button(driver, browser, mode, device, username, password): """Test the cart page's checkout button.""" # Note: SauceDemo intentionally allows you to checkout with no items. This case is explicitly # tested in test_cart_page.py in test_checkout_no_items() login_page = LoginPage(driver) login_page.perform_complete_login(username, password) product_page = ProductListPage(driver) product_page.click_cart() cart_page = CartPage(driver) cart_page.click_checkout()
def test_continue_shopping_button(driver, browser, mode, device, username, password): """Test the cart page's continue shopping button.""" login_page = LoginPage(driver) login_page.perform_complete_login(username, password) product_page = ProductListPage(driver) product_page.click_cart() cart_page = CartPage(driver) cart_page.click_continue_shopping() assert len(product_page.get_list_of_product_names()) > 0
def test_cancel_button(driver, browser, mode, device, username, password): """Test the checkout page's cancel button.""" login_page = LoginPage(driver) login_page.perform_complete_login(username, password) product_page = ProductListPage(driver) product_page.click_cart() cart_page = CartPage(driver) cart_page.click_checkout() checkout_page = CheckoutPage(driver) checkout_page.click_cancel() assert cart_page.get_subheader() == "Your Cart"
def test_checkout_one_item(driver, browser, mode, device, username, password): """Test the checkout process with one item.""" login_page = LoginPage(driver) login_page.perform_complete_login(username, password) product_list_page = ProductListPage(driver) add_to_cart_buttons = product_list_page.get_add_to_cart_buttons() num_items_in_cart = 0 assert product_list_page.get_number_cart_items() == num_items_in_cart, \ "An unexpected item has been found in the cart." item_button = random.choice(add_to_cart_buttons) item_button.click() assert item_button.text == REMOVE assert product_list_page.get_number_cart_items() == 1, \ "An unexpected item has been found in the cart." # Continue to the cart page product_list_page.click_cart() cart_page = CartPage(driver) cart_total = cart_page.get_sum_prices() cart_page.click_checkout() checkout_page = CheckoutPage(driver) checkout_page.click_continue() assert checkout_page.is_error_message_present() # Input checkout information. first_name = "Testy" last_name = "McTest" postal_code = "08221" checkout_page.input_first_name(first_name) checkout_page.input_last_name(last_name) checkout_page.input_postal_code(postal_code) checkout_page.input_payment_details( ) # A real e-commerce site would allow you to add payment info. assert checkout_page.get_first_name() == first_name assert checkout_page.get_last_name() == last_name assert checkout_page.get_postal_code() == postal_code checkout_page.click_continue() # Check the overview page before completing the order. overview_page = OverviewPage(driver) assert overview_page.get_subheader() == "Checkout: Overview" assert cart_total == overview_page.get_subtotal() overview_page.click_finish() # Check the order confirmation page. order_confirmation_page = OrderConfirmationPage(driver) assert order_confirmation_page.get_subheader() == "Finish" assert product_list_page.get_number_cart_items( ) == 0, "Unexpected item found in cart."
def setUpClass(cls): # chromedriver = "C:/Users/Administrator/AppData/Local/Google/Chrome/Application/chromedriver.exe" cls.driver = webdriver.Chrome(executable_path=chromedriver) cls.driver.implicitly_wait(5) # 隐式等待 cls.url = test_url cls.username = username cls.password = "******" cls.public_page = PublicMethod(cls.driver, cls.url, u"合纵易购收藏界面") # 声明PublicMethod类对象 cls.home_page = HomePage(cls.driver, cls.url, u"合纵易购收藏界面") # 声明homePage类对象 cls.cart_page = CartPage(cls.driver, cls.url, u"合纵易购收藏界面") # 声明cartPage类对象 cls.categories_page = CategoriesPage( cls.driver, cls.url, u"合纵易购收藏界面") # 声明categoriesPage类对象 cls.puyao_page = PuYaoPage(cls.driver, cls.url, u"合纵易购收藏界面") # 声明puyaoPage类对象 cls.settle_page = SettlePage(cls.driver, cls.url, u"合纵易购收藏界面") # 声明settlePage类对象 cls.goodsdetail_page = GoodsDetailPage( cls.driver, cls.url, u"合纵易购收藏界面") # 声明goodsDetailPage类对象 cls.collection_page = CollectionPage( cls.driver, cls.url, u"合纵易购收藏界面") # 声明collectionPage类对象 cls.zhongyao_page = ZhongYaoPage(cls.driver, cls.url, u"合纵易购收藏界面") # 声明ZhongYaoPage类对象 cls.public_page.get_url(cls.url) cls.public_page.is_element_exist() # 判断广告页是否弹出,弹出自动关闭 cls.public_page.login(cls.username, cls.password) cls.public_page.is_element_exist() # 判断广告页是否弹出,弹出自动关闭
def setUpClass(cls): # chromedriver = "C:/Users/Administrator/AppData/Local/Google/Chrome/Application/chromedriver.exe" cls.driver = webdriver.Chrome(executable_path=chromedriver) cls.url = test_url cls.public_page = PublicMethod(cls.driver, cls.url, u"合纵药易购商品分类界面") # 声明publicMethod类对象 cls.categories_page = CategoriesPage( cls.driver, cls.url, u"合纵药易购结算界面") # 声明categoriesPage类对象 cls.home_page = HomePage(cls.driver, cls.url, u"合纵药易购结算界面") # 声明homepage类对象 cls.puyao_page = PuYaoPage(cls.driver, cls.url, u"合纵药易购结算界面") # 声明puyaopage类对象 cls.settle_page = SettlePage(cls.driver, cls.url, u"合纵药易购结算界面") # 声明settlepage类对象 cls.cart_page = CartPage(cls.driver, cls.url, u"合纵药易购结算界面") # 声明cartpage类对象 cls.order_page = OrderPage(cls.driver, cls.url, u"合纵药易购结算界面") # 声明orderpage类对象 cls.driver.implicitly_wait(5) cls.username = username cls.password = "******" cls.ddbz = "订单备注" cls.public_page.get_url(cls.url) cls.public_page.is_element_exist() # 判断广告页是否弹出,弹出自动关闭 cls.public_page.login(cls.username, cls.password) cls.public_page.is_element_exist() # 判断广告页是否弹出,弹出自动关闭
def test_checkout_no_items(driver, browser, mode, device, username, password): """Checkout with no items. SwagLabs allows this even when logging in with standard_user.""" login_page = LoginPage(driver) login_page.perform_complete_login(username, password) product_list_page = ProductListPage(driver) product_list_page.click_cart() # Continue to cart page with no items. cart_page = CartPage(driver) cart_page.click_checkout() checkout_page = CheckoutPage(driver) checkout_page.click_continue() assert checkout_page.is_error_message_present() # Enter name and postal code first_name = "Testy" last_name = "McTest" postal_code = "08221" checkout_page.input_first_name(first_name) checkout_page.input_last_name(last_name) checkout_page.input_postal_code(postal_code) checkout_page.input_payment_details() assert checkout_page.get_first_name() == first_name assert checkout_page.get_last_name() == last_name assert checkout_page.get_postal_code() == postal_code checkout_page.click_continue() # Check the overview page before completing the order. overview_page = OverviewPage(driver) assert overview_page.get_subheader() == "Checkout: Overview" overview_page.click_finish() # Check the order confirmation page. order_confirmation_page = OrderConfirmationPage(driver) assert order_confirmation_page.get_subheader() == "Finish" assert product_list_page.get_number_cart_items( ) == 0, "Unexpected item found in cart."
def setUp(self): # chromedriver = "C:/Users/Administrator/AppData/Local/Google/Chrome/Application/chromedriver.exe" self.driver = webdriver.Chrome(executable_path=chromedriver) self.driver.implicitly_wait(30) self.url1 = login_url self.url2 = tejia_url self.username1 = "测试05" # 非区域会员 self.username2 = "测试06" # 非终端会员 self.username3 = "测试07" # 正常会员 self.password = "******" # 密码 self.public_page = PublicMethod(self.driver, self.url, u"合纵易购特价界面") # 声明publicMethod类对象 self.login_page = LoginPage(self.driver, self.url, u"合纵易购特价界面") # 声明LoginPage类对象 self.tejia_page = TeJiaPage(self.driver, self.url, u"合纵易购特价界面") # 声明TeJiaPage类对象 self.goodDetail_page = GoodsDetailPage( self.driver, self.url, u"合纵易购特价界面") # 声明GoodsDetailPage self.cart_page = CartPage(self.driver, self.url, u"合纵易购特价界面") # 声明cartPage self.home_page = HomePage(self.driver, self.url, u"合纵易购特价界面") # 声明homePage self.settle_page = SettlePage(self.driver, self.url, u"合纵易购特价界面") # 声明settlePage
def setUp(self): # chromedriver = "C:/Users/Administrator/AppData/Local/Google/Chrome/Application/chromedriver.exe" self.driver = webdriver.Chrome(executable_path=chromedriver) self.url = test_url self.public_page = PublicMethod(self.driver, self.url, u"合纵药易购订单界面") # 声明publicMethod类对象 self.categories_page = CategoriesPage( self.driver, self.url, u"合纵药易购订单界面") # 声明categoriesPage类对象 self.home_page = HomePage(self.driver, self.url, u"合纵药易购订单界面") # 声明homepage类对象 self.puyao_page = PuYaoPage(self.driver, self.url, u"合纵药易购订单界面") # 声明puyaopage类对象 self.jpzq_page = JingPinZhuanQuPage( self.driver, self.url, u"合纵药易购订单界面") # 声明jingpinzhuanqu类对象 self.settle_page = SettlePage(self.driver, self.url, u"合纵药易购订单界面") # 声明settlepage类对象 self.cart_page = CartPage(self.driver, self.url, u"合纵药易购订单界面") # 声明cartpage类对象 self.order_page = OrderPage(self.driver, self.url, u"合纵药易购订单界面") # 声明orderpage类对象 self.zhongyao_page = ZhongYaoPage(self.driver, self.url, u"合纵药易购订单界面") # 声明zhongyaoPage类对象 self.goodsDetail_Page = GoodsDetailPage( self.driver, self.url, u"合纵药易购订单界面") # 声明GoodsDetailPage类对象 self.search_page = SearchPage(self.driver, self.url, u"合纵药易购订单界面") # 声明SearchPage类对象 self.driver.implicitly_wait(5) self.ssnr = "阿胶" self.username = username self.password = "******" self.ddbz = "订单备注" self.shuliang = 20 self.public_page.get_url(self.url) self.public_page.is_element_exist() # 判断广告页是否弹出,弹出自动关闭 self.public_page.login(self.username, self.password) self.public_page.is_element_exist() # 判断广告页是否弹出,弹出自动关闭
def setUpClass(cls): # chromedriver = "C:/Users/Administrator/AppData/Local/Google/Chrome/Application/chromedriver.exe" cls.driver = webdriver.Chrome(executable_path=chromedriver) cls.driver.implicitly_wait(5) # 隐式等待 cls.url = test_url cls.username = username cls.password = "******" cls.public_page = PublicMethod(cls.driver, cls.url, u"合纵易购积分商城界面") # 声明PublicMethod类对象 cls.home_page = HomePage(cls.driver, cls.url, u"合纵易购积分商城界面") # 声明homePage类对象 cls.cart_page = CartPage(cls.driver, cls.url, u"合纵易购积分商城界面") # 声明cartPage类对象 cls.categories_page = CategoriesPage( cls.driver, cls.url, u"合纵易购积分商城界面") # 声明categoriesPage类对象 cls.puyao_page = PuYaoPage(cls.driver, cls.url, u"合纵易购积分商城界面") # 声明puyaoPage类对象 cls.settle_page = SettlePage(cls.driver, cls.url, u"合纵易购积分商城界面") # 声明settlePage类对象 cls.goodsdetail_page = GoodsDetailPage( cls.driver, cls.url, u"合纵易购积分商城界面") # 声明goodsDetailPage类对象 cls.jfsc_page = JiFenShangChengPage( cls.driver, cls.url, u"合纵易购积分商城界面") # 声明jifenshangchengPage类对象 cls.jfscqd_page = JiFenShangCheng_qiandaoPage( cls.driver, cls.url, u"合纵易购积分商城界面") # 声明JiFenShangCheng_qiandaoPage类对象 cls.jfscgrzx_page = JiFenShangCheng_gerenzhongxinPage( cls.driver, cls.url, u"合纵易购积分商城界面") # 声明JiFenShangCheng_grzxPage类对象 cls.jfsclpc_page = JiFenShangCheng_lipinchePage( cls.driver, cls.url, u"合纵易购积分商城界面") # 声明JiFenShangCheng_lpcPage类对象 cls.jfscddxq_page = JiFenShangCheng_ddxqPage( cls.driver, cls.url, u"合纵易购积分商城界面") # 声明积分商城订单界面类对象 cls.public_page.get_url(cls.url) cls.public_page.is_element_exist() # 判断广告页是否弹出,弹出自动关闭 cls.public_page.login(cls.username, cls.password) cls.public_page.is_element_exist() # 判断广告页是否弹出,弹出自动关闭
class TestLogin(unittest.TestCase): def setUp(self): # chromedriver = "C:/Users/Administrator/AppData/Local/Google/Chrome/Application/chromedriver.exe" self.driver = webdriver.Chrome(executable_path=chromedriver) self.driver.implicitly_wait(30) self.url1 = login_url self.url2 = tejia_url self.username1 = "测试05" # 非区域会员 self.username2 = "测试06" # 非终端会员 self.username3 = "测试07" # 正常会员 self.password = "******" # 密码 self.public_page = PublicMethod(self.driver, self.url, u"合纵易购特价界面") # 声明publicMethod类对象 self.login_page = LoginPage(self.driver, self.url, u"合纵易购特价界面") # 声明LoginPage类对象 self.tejia_page = TeJiaPage(self.driver, self.url, u"合纵易购特价界面") # 声明TeJiaPage类对象 self.goodDetail_page = GoodsDetailPage( self.driver, self.url, u"合纵易购特价界面") # 声明GoodsDetailPage self.cart_page = CartPage(self.driver, self.url, u"合纵易购特价界面") # 声明cartPage self.home_page = HomePage(self.driver, self.url, u"合纵易购特价界面") # 声明homePage self.settle_page = SettlePage(self.driver, self.url, u"合纵易购特价界面") # 声明settlePage def tearDownClass(self): self.driver.quit() def test_tejia_01(self): """非区域内的会员""" self.public_page.get_url(login_url) # 进入首页 sleep(1) self.public_page.login(self.username1, self.password) # 登录账号 sleep(1) self.public_page.get_url(tejia_url) # 进入特价页面 sleep(1) self.assertEqual(self.tejia_page.text_qyts, "该活动针对非成都地区终端客户!") def test_tejia_02(self): """非终端会员""" self.public_page.get_url(login_url) # 进入首页 sleep(1) self.public_page.login(self.username1, self.password) # 登录账号 sleep(1) self.public_page.get_url(tejia_url) # 进入特价页面 sleep(1) self.assertEqual(self.tejia_page.text_zdts(), "只有终端可以参与活动!") def test_tejia_03(self): """加入购物车""" self.public_page.get_url(login_url) # 进入首页 sleep(1) self.public_page.login(self.username1, self.password) # 登录账号 sleep(1) self.public_page.get_url(tejia_url) # 进入特价页面 sleep(1) self.tejia_page.click_jrgwc() # 加入购物车 sleep(1) self.tejia_page.click_yxgpz() # 进入已选购页面 sleep(1) self.assertEqual(self.tejia_page.text_jrgwc(), "加入购物车") def test_tejia_04(self): """搜索相应商品""" self.public_page.get_url(login_url) # 进入首页 sleep(1) self.public_page.login(self.username1, self.password) # 登录账号 sleep(1) self.public_page.get_url(tejia_url) # 进入特价页面 sleep(1) self.tejia_page.input_ssk("川贝") sleep(1) self.tejia_page.click_ssButton() sleep(1) self.assertEqual(self.tejia_page.text_spTitle(), "川贝粉") def test_tejia_05(self): """商品详情中价格检查""" self.public_page.get_url(login_url) # 进入首页 sleep(1) self.public_page.login(self.username1, self.password) # 登录账号 sleep(1) self.public_page.get_url(tejia_url) # 进入特价页面 sleep(1) a = self.tejia_page.text_tj() # 获取特价价格 sleep(1) self.tejia_page.click_spdt() # 点击商品大图 sleep(1) b = self.goodDetail_page.text_tj() # 获取特价价格 sleep(1) self.assertEqual(a, b) # 判断特价列表和商品详情的价格是否一致 def test_tejia_06(self): """购物车中的价格检查""" self.public_page.get_url(login_url) # 进入首页 sleep(1) self.public_page.login(self.username1, self.password) # 登录账号 sleep(1) self.public_page.get_url(tejia_url) # 进入特价页面 sleep(1) a = self.tejia_page.text_tj() # 获取特价价格 sleep(1) self.tejia_page.click_spdt() # 点击商品大图 sleep(1) self.goodDetail_page.click_jrgwc() # 点击加入购物车 sleep(1) self.home_page.click_gwc() # 点击购物车 sleep(1) b = self.cart_page.text_dj() # 获取单价 sleep(1) self.assertEqual(a, b) def test_tejia07(self): """结算中的价格检查""" self.public_page.get_url(login_url) # 进入首页 sleep(1) self.public_page.login(self.username1, self.password) # 登录账号 sleep(1) self.public_page.get_url(tejia_url) # 进入特价页面 sleep(1) a = self.tejia_page.text_tj() # 获取特价价格 sleep(1) self.tejia_page.click_spdt() # 点击商品大图 sleep(1) self.goodDetail_page.click_jrgwc() # 点击加入购物车 sleep(1) self.home_page.click_gwc() # 点击购物车 sleep(1) self.cart_page.click_jiesuan() # 点击结算 sleep(1) b = self.settle_page.text_dj() # 获取单价 sleep(1) self.assertAlmostEqual(a, b)
class TestOrderProcess(unittest.TestCase): @classmethod def setUpClass(cls): pass def setUp(self): # chromedriver = "C:/Users/Administrator/AppData/Local/Google/Chrome/Application/chromedriver.exe" self.driver = webdriver.Chrome(executable_path=chromedriver) self.url = test_url self.public_page = PublicMethod(self.driver, self.url, u"合纵药易购订单界面") # 声明publicMethod类对象 self.categories_page = CategoriesPage( self.driver, self.url, u"合纵药易购订单界面") # 声明categoriesPage类对象 self.home_page = HomePage(self.driver, self.url, u"合纵药易购订单界面") # 声明homepage类对象 self.puyao_page = PuYaoPage(self.driver, self.url, u"合纵药易购订单界面") # 声明puyaopage类对象 self.jpzq_page = JingPinZhuanQuPage( self.driver, self.url, u"合纵药易购订单界面") # 声明jingpinzhuanqu类对象 self.settle_page = SettlePage(self.driver, self.url, u"合纵药易购订单界面") # 声明settlepage类对象 self.cart_page = CartPage(self.driver, self.url, u"合纵药易购订单界面") # 声明cartpage类对象 self.order_page = OrderPage(self.driver, self.url, u"合纵药易购订单界面") # 声明orderpage类对象 self.zhongyao_page = ZhongYaoPage(self.driver, self.url, u"合纵药易购订单界面") # 声明zhongyaoPage类对象 self.goodsDetail_Page = GoodsDetailPage( self.driver, self.url, u"合纵药易购订单界面") # 声明GoodsDetailPage类对象 self.search_page = SearchPage(self.driver, self.url, u"合纵药易购订单界面") # 声明SearchPage类对象 self.driver.implicitly_wait(5) self.ssnr = "阿胶" self.username = username self.password = "******" self.ddbz = "订单备注" self.shuliang = 20 self.public_page.get_url(self.url) self.public_page.is_element_exist() # 判断广告页是否弹出,弹出自动关闭 self.public_page.login(self.username, self.password) self.public_page.is_element_exist() # 判断广告页是否弹出,弹出自动关闭 def tearDown(self): self.driver.quit() sleep(2) @classmethod def tearDownClass(cls): # chromedriver = "C:/Users/Administrator/AppData/Local/Google/Chrome/Application/chromedriver.exe" # cls.driver = webdriver.Chrome(executable_path=chromedriver) # cls.driver.quit() pass def test_OrderProcess_01(self): """测试下单前检查清除购物车商品""" sleep(1) self.categories_page.click_py() # 点击进入普药列表 sleep(2) self.home_page.click_gwc() # 进入购物车界面 sleep(1) self.cart_page.is_scsp_exist() # 判断是否存在商品 sleep(1) self.driver.back() # 返回首页 sleep(1) self.public_page.is_element_exist() # 判断广告也是否弹出,弹出自动关闭 def test_OrderProcess_02(self): """在普药中选择商品进行下单""" sleep(2) self.categories_page.click_py() # 点击普药进入普药列表 sleep(0.5) for i in range(3): sleep(1) self.puyao_page.click_addcart(i) # 点击第一个商品加入购物车 sleep(2) self.home_page.click_gwc() # 进入购物车界面 for i in range(3): sleep(1) self.cart_page.input_number1(self.shuliang, i) sleep(1) self.cart_page.click_jiesuan() # 点击结算按钮 sleep(1) self.public_page.click_tckLeft() # 结算后的提示框点击 sleep(1) # self.settle_page.click_tjdd() # 点击提交订单 # sleep(1) # self.assertEqual(self.order_page.text_cgts(), "感谢您在本网站购买商品,您的订单已成功提交!") def test_OrderProcess_03(self): """在精品专区中选择商品进行下单""" sleep(2) self.categories_page.click_jpzq() # 点击精品专区进入精品列表 for i in range(3): sleep(2) self.jpzq_page.click_addcart(i) # 输入第一个商品加入购物车 sleep(1) self.home_page.click_gwc() # 进入购物车界面 sleep(2) for i in range(3): sleep(1) self.cart_page.input_number1(self.shuliang, i) sleep(0.5) self.cart_page.click_jiage() sleep(1) self.cart_page.click_jiesuan() # 点击结算按钮 # sleep(0.5) # self.settle_page.click_tjdd() # 点击提交订单 # sleep(0.5) # self.assertEqual(self.order_page.text_cgts(), "感谢您在本网站购买商品,您的订单已成功提交!") def test_OrderProcess_04(self): """在中药专区选择商品进行下单""" sleep(1) self.categories_page.click_zyzq() # 点击进入中药专区 sleep(1) self.zhongyao_page.click_ljqg(0) # 点击第一个商品立即抢购 sleep(1) self.public_page.switch_secendPage() # 句柄切换到第二页中 sleep(1) self.goodsDetail_Page.click_jrgwc() # 点击加入购物车 sleep(1) self.driver.close() # 退出商品详情页面 sleep(1) self.public_page.switch_home() # 句柄切换到首页 sleep(1) self.zhongyao_page.click_ljqg(1) # 点击第二个商品立即抢购 sleep(1) self.public_page.switch_secendPage() # 句柄切换到第二页 sleep(1) self.goodsDetail_Page.click_jrgwc() # 点击加入购物车 sleep(1) self.goodsDetail_Page.click_gwc() # 点击购物车按钮 for i in range(2): sleep(1) self.cart_page.input_number1(self.shuliang, i) # 输入第一个商品的数量 sleep(1) self.cart_page.click_jiage() sleep(1) self.cart_page.click_jiesuan() # 点击结算按钮 sleep(0.5) # self.settle_page.click_tjdd() # 点击提交订单 # sleep(0.5) # self.assertEqual(self.order_page.text_cgts(), "感谢您在本网站购买商品,您的订单已成功提交!") def test_OrderProcess_05(self): """呼吸系统用药商品下单""" sleep(2) self.categories_page.click_qbspfl(0) # 点击进入呼吸系统分类选择 sleep(0.5) self.categories_page.click_list1_1() # 点击进入抗感冒类界面 sleep(1) self.public_page.switch_secendPage() # 句柄切换到第二页上 for i in range(2): sleep(0.5) self.puyao_page.click_addcart(i) # 商品1加入购物车 sleep(2) self.home_page.click_gwc() # 调用进入购物车界面按钮 sleep(0.5) self.cart_page.input_number1(self.shuliang, 0) # 输入第一个商品的数量 sleep(2) self.cart_page.input_number1(self.shuliang, 1) # 输入第二个商品的数量 sleep(1) self.cart_page.click_jiesuan() # 点击结算按钮 # sleep(0.5) # self.settle_page.click_tjdd() # 点击提交订单 # sleep(0.5) # self.assertEqual(self.order_page.text_cgts(), "感谢您在本网站购买商品,您的订单已成功提交!") def test_OrderProcess_06(self): """清热消炎商品下单""" sleep(0.5) self.categories_page.click_qbspfl(1) # 点击进入呼吸系统分类选择 sleep(0.5) self.categories_page.click_list2_1() # 点击进入抗感冒类界面 sleep(0.5) self.public_page.switch_secendPage() # 句柄切换到第二页上 for i in range(3): sleep(1) self.puyao_page.click_addcart(i) # 商品1加入购物车 sleep(5) self.home_page.click_gwc() # 调用进入购物车界面按钮 for i in range(3): sleep(1) self.cart_page.input_number1(self.shuliang, i) # 给一二三个商品添加数量 sleep(1) self.cart_page.click_jiesuan() # 点击结算按钮 # sleep(0.5) # self.settle_page.click_tjdd() # 点击提交订单 # sleep(0.5) # self.assertEqual(self.order_page.text_cgts(), "感谢您在本网站购买商品,您的订单已成功提交!") def test_OrderProcess_07(self): """五官皮肤及外用商品下单""" sleep(0.5) self.categories_page.click_qbspfl(2) # 点击进入呼吸系统分类选择 sleep(0.5) self.categories_page.click_list3_1() # 点击进入抗感冒类界面 sleep(0.5) self.public_page.switch_secendPage() # 句柄切换到第二页上 for i in range(3): sleep(1) self.puyao_page.click_addcart(i) # 商品1加入购物车 sleep(2) self.home_page.click_gwc() # 调用进入购物车界面按钮 sleep(1) for i in range(2): self.cart_page.input_number1(self.shuliang, 0) # 调用给第一个商品输入数量 sleep(2) self.cart_page.click_jiesuan() # 点击结算按钮 # sleep(0.5) # self.settle_page.click_tjdd() # 点击提交订单 # sleep(0.5) # self.assertEqual(self.order_page.text_cgts(), "感谢您在本网站购买商品,您的订单已成功提交!") def test_OrderProcess_08(self): """补益安神及维矿类商品下单""" sleep(0.5) self.categories_page.click_qbspfl(4) # 点击进入呼吸系统分类选择 sleep(0.5) self.categories_page.click_list5_1() # 点击进入抗感冒类界面 sleep(0.5) self.public_page.switch_secendPage() # 句柄切换到第二页上 for i in range(3): sleep(1) self.puyao_page.click_addcart(i) # 商品1加入购物车 sleep(2) self.home_page.click_gwc() # 调用进入购物车界面按钮 sleep(1) for i in range(3): self.cart_page.input_number1(self.shuliang, i) # 输入第一个商品的数量 sleep(1) self.cart_page.click_jiesuan() # 点击结算按钮 # sleep(0.5) # self.settle_page.click_tjdd() # 点击提交订单 # sleep(0.5) # self.assertEqual(self.order_page.text_cgts(), "感谢您在本网站购买商品,您的订单已成功提交!") def test_OrderProcess_09(self): """商品分类——妇、儿科列表""" sleep(0.5) self.categories_page.click_qbspfl(5) # 点击进入呼吸系统分类选择 sleep(0.5) self.categories_page.click_list6_1() # 点击进入抗感冒类界面 sleep(0.5) self.public_page.switch_secendPage() # 句柄切换到第二页上 sleep(1) for i in range(3): self.puyao_page.click_addcart(i) # 商品1加入购物车 sleep(1) sleep(1) self.home_page.click_gwc() # 调用进入购物车界面按钮 sleep(1) for i in range(3): self.cart_page.input_number1(self.shuliang, i) # 输入第N个商品的数量 sleep(1) self.cart_page.click_jiesuan() # 点击结算按钮 # sleep(0.5) # self.settle_page.click_tjdd() # 点击提交订单 # sleep(0.5) # self.assertEqual(self.order_page.text_cgts(), "感谢您在本网站购买商品,您的订单已成功提交!") def test_OrderProcess_10(self): """商品分类——心脑血管及神经类用药列表""" sleep(0.5) self.categories_page.click_qbspfl(6) # 点击进入呼吸系统分类选择 sleep(0.5) self.categories_page.click_list7_1() # 点击进入抗感冒类界面 sleep(0.5) self.public_page.switch_secendPage() # 句柄切换到第二页上 for i in range(2): sleep(1) self.puyao_page.click_addcart(i) # 商品2加入购物车 sleep(5) self.home_page.click_gwc() # 调用进入购物车界面按钮 sleep(1) for i in range(3): self.cart_page.input_number1(self.shuliang, i) # 输入第一个商品的数量 sleep(1) self.cart_page.click_jiesuan() # 点击结算按钮 # sleep(0.5) # self.settle_page.click_tjdd() # 点击提交订单 # sleep(0.5) # self.assertEqual(self.order_page.text_cgts(), "感谢您在本网站购买商品,您的订单已成功提交!") def test_OrderProcess_11(self): """商品分类——风湿骨伤及其他药品列表""" sleep(0.5) self.categories_page.click_qbspfl(8) # 点击进入呼吸系统分类选择 sleep(0.5) self.categories_page.click_list9_1() # 点击进入抗感冒类界面 sleep(0.5) self.public_page.switch_secendPage() # 句柄切换到第二页上 for i in range(2): sleep(1) self.puyao_page.click_addcart(i) # 商品2加入购物车 sleep(2) self.home_page.click_gwc() # 调用进入购物车界面按钮 sleep(1) for i in range(3): self.cart_page.input_number1(self.shuliang, i) # 输入第一个商品的数量 sleep(1) self.cart_page.click_jiesuan() # 点击结算按钮 # sleep(0.5) # self.settle_page.click_tjdd() # 点击提交订单 # sleep(0.5) # self.assertEqual(self.order_page.text_cgts(), "感谢您在本网站购买商品,您的订单已成功提交!") def test_OrderProcess_12(self): """商品分类——非药品列表""" sleep(0.5) self.categories_page.click_qbspfl(11) # 点击进入呼吸系统分类选择 sleep(0.5) self.categories_page.click_list12_1() # 点击进入抗感冒类界面 sleep(0.5) self.public_page.switch_secendPage() # 句柄切换到第二页上 for i in range(2): sleep(1) self.puyao_page.click_addcart(i) # 商品2加入购物车 sleep(2) self.home_page.click_gwc() # 调用进入购物车界面按钮 sleep(0.5) for i in range(3): self.cart_page.input_number1(self.shuliang, i) # 输入第一个商品的数量 sleep(1) self.cart_page.click_jiesuan() # 点击结算按钮 # sleep(0.5) # self.settle_page.click_tjdd() # 点击提交订单 # sleep(0.5) # self.assertEqual(self.order_page.text_cgts(), "感谢您在本网站购买商品,您的订单已成功提交!") def test_OrderProcess_13(self): """搜索内容进行下单""" sleep(1) self.search_page.input_ssk("阿胶") # 搜索框中输入内容 sleep(1) self.search_page.click_ssButton() # 点击搜索按钮 sleep(1) for i in range(2): sleep(1) self.puyao_page.click_addcart(i) # 商品2加入购物车 sleep(2) self.home_page.click_gwc() # 调用进入购物车界面按钮 sleep(0.5) for i in range(2): self.cart_page.input_number1(self.shuliang, i) # 输入第一个商品的数量 sleep(1) sleep(1) self.cart_page.click_jiesuan() # 点击结算按钮 # sleep(0.5) # self.settle_page.click_tjdd() # 点击提交订单 # sleep(0.5) # self.assertEqual(self.order_page.text_cgts(), "感谢您在本网站购买商品,您的订单已成功提交!") def test_OrderProcess_14(self): """搜索框联想的内容进行下单""" sleep(2) self.search_page.input_ssk("阿胶") # 搜索框中输入内容 sleep(2) self.search_page.click_ssList1(0) # 点击搜索列表第一个 sleep(2) for i in range(2): sleep(1) self.puyao_page.click_addcart(i) # 商品2加入购物车 sleep(2) self.home_page.click_gwc() # 调用进入购物车界面按钮 sleep(0.5) for i in range(2): self.cart_page.input_number1(self.shuliang, i) # 输入第一个商品的数量 sleep(1) sleep(1) self.cart_page.click_jiesuan() # 点击结算按钮