def test_usupported_zipcode(self): placeorder = PlaceOrder(Browser._driver) negativecases = NegativeCases(Browser._driver) time.sleep(10) # Find the selected product and click on it placeorder.findproductandclick(self.Negativeresult[0][0]) # Wait till the Product Details page is loaded BasicActions.implicit_wait(30) if placeorder.wait_for_product_page(): self.assertTrue(negativecases.unsupported_zip_code(self.Negativeresult[1][0], self.Negativeresult[4][0], self.Negativeresult[9][0], self.Negativeresult[10][0]), "Unsupported Zip Code is accepted")
def test_invalid_name(self): placeorder = PlaceOrder(Browser._driver) negativecases = NegativeCases(Browser._driver) time.sleep(10) # Find the selected product and click on it placeorder.findproductandclick(self.Negativeresult[0][0]) # Wait till the Product Details page is loaded BasicActions.implicit_wait(30) if placeorder.wait_for_product_page(): self.assertTrue(negativecases.invalid_name(self.Negativeresult[2][0], self.Negativeresult[5][0], self.Negativeresult[8][0]), "Invalid Name is accepted")
def test_missing_name_zipcode(self): placeorder = PlaceOrder(Browser._driver) negativecases = NegativeCases(Browser._driver) time.sleep(10) # Find the selected product and click on it placeorder.findproductandclick(self.Negativeresult[0][0]) # Wait till the Product Details page is loaded BasicActions.implicit_wait(30) if placeorder.wait_for_product_page(): self.assertTrue(negativecases.no_name_zipcode(self.Negativeresult[6][0]), "Missing Name or Zip Code are accepted")
def test_productimage_with_pick_me_button(self): placeorder = PlaceOrder(Browser._driver) # Find the selected product and click on it negativecases = NegativeCases(Browser._driver) time.sleep(10) placeorder.findproductandclick(self.Negativeresult[0][0]) # Wait till the Product Details page is loaded BasicActions.implicit_wait(30) if placeorder.wait_for_product_page(): self.assertTrue(negativecases.product_image_click(),"Clicking on Product image and pick me button are not correct")
def setUp(cls): # Create a new Browser session and maximize the window Browser.initialize_driver() # default FireFox BasicActions.maximize_window() # Go to Olyve Home Page URL BasicActions.navigate(ConfigReader.readconfig('ConfigurationSettings','OlyveHomeURL')) # Wait till the Home page is loaded placeorder = PlaceOrder(Browser._driver) placeorder.wait_for_header_olyve_logo()
def test_Markete2e(self): log = self.getlogger() log.info("Market webpage automation is started...") homepage = Homepage(self.driver) log.info("Searching for carrot by typing 'ro' in the search box. ") homepage.getSearch().send_keys("ro") sleep(2) items = homepage.getProduct() for i in items: name = i.find_element_by_xpath("h4").text if name == 'Carrot - 1 Kg': log.info(name + " Item has been selected.") #assert "pat" in name price = i.find_element_by_xpath("p").text log.info("Its price is " + price) i.find_element_by_css_selector("[type=button]").click() log.info("Added to cart !") homepage.getSearch().clear() sleep(2) log.info( "Searching for Nuts Mixture by typing 'nut' in the search box. ") homepage.getSearch().send_keys("nut") sleep(2) items = homepage.getProduct() for i in items: name = i.find_element_by_xpath("h4").text if name == 'Nuts Mixture - 1 Kg': log.info(name + " Item has been selected.") # assert "pat" in name price = i.find_element_by_xpath("p").text log.info("Its price is " + price) log.info("Quantity is increased by one !") i.find_element_by_xpath("//a[@class='increment']").click() log.info("Two " + name + " has selected to order !") sleep(2) i.find_element_by_css_selector("[type=button]").click() log.info("Added to cart !") log.info("Total price for 2 " + name + " is 1900") homepage.getCart().click() log.info("Went to cart !") sleep(2) homepage.getPTC().click() sleep(2) placeorder = PlaceOrder(self.driver) amount = placeorder.getAmount().text log.info("Total amount " + amount) placeorder.getPromocode().send_keys("rahulshettyacademy") log.info("Applying Coupon...") placeorder.getApply().click() sleep(8) log.info(self.driver.find_element_by_css_selector(".promoInfo").text) disamount = placeorder.getAmount().text log.info("Total amount after discount " + disamount) placeorder.getplace().click() log.info("Now placing order.") conformpage = ConformPage(self.driver) country = Select(conformpage.getCountry()) country.select_by_visible_text("India") log.info("Country has been selected !") sleep(2) conformpage.getagreechkbtn().click() log.info("Terms and conditions accepted !") conformpage.getProceed().click() log.info("Hurry ! Your order has been placed successfully.")
def test_place_product_order(self): placeorder = PlaceOrder(Browser._driver) for row_index in range(len(self.OrderInforesult[0])): if self.OrderInforesult[0][row_index] is not None: # Find the selected product and click on it placeorder.findproductandclick(self.OrderInforesult[0][row_index]) # Wait till the Product Details page is loaded BasicActions.implicit_wait(50) if placeorder.wait_for_product_page(): # Get Price of the Product as it will be required in the Review page product_price = placeorder.get_product_price() # Click on the Pick Me button placeorder.click_on_pickme_button() # Wait till The "WHO ARE WE DELIVERING TO" popup is displayed BasicActions.implicit_wait(20) # Fill the "WHO ARE WE DELIVERING TO" popup with data set in the input excel file placeorder.fill_pickme_popup(self.OrderInforesult[2][row_index], self.OrderInforesult[3][row_index]) # Wait until the next page is opened if (placeorder.wait_for_accessory_page())or (placeorder.wait_for_message_page()): # Get the URL of the current page current_url = Browser._driver.current_url # Check if the Page opened is the Accessory page and accessory value is yes if current_url == self.GeneralInforesult[1][0] and self.OrderInforesult[4][row_index] == 'Yes': # Get the Accessory Price from the page as it will be required in the Review Order Page accessory_price = placeorder.get_accessory_price() # Click on Yes Please button placeorder.click_yesplease() # Check if this product has no accessory and user is directed to message page elif current_url == self.GeneralInforesult[1][1]: accessory_price = 0 # Check if the user required to click on No button if accessory is not required else: # Set accessory price to zero in case no accessory is required accessory_price = 0 # Click on No Thanks button placeorder.click_nothanks() # Wait till the Message page is loaded BasicActions.implicit_wait(30) if placeorder.wait_for_message_page(): # Get the URL of the current page current_url = Browser._driver.current_url # Check if the current page is message page if current_url == self.GeneralInforesult[1][1]: # Fill the gift Message and Signature placeorder.fill_gift_message(self.OrderInforesult[5][row_index], self.OrderInforesult[6][row_index]) # Upload the Photo from given location placeorder.upload_photo(self.OrderInforesult[7][row_index]) # Upload Video from given location placeorder.upload_video(self.OrderInforesult[8][row_index]) # Click on the Review and Checkout button placeorder.click_review_and_checkout() # Wait till the Checkout page is loaded if placeorder.wait_for_checkout_page(): current_url = Browser._driver.current_url if current_url == self.GeneralInforesult[1][2]: # Verified the Product Name self.assertTrue(placeorder.check_product_name(self.OrderInforesult[1][row_index]), "Product Name doesn't match the selected product name") self.assertTrue(placeorder.check_product_name_review(self.OrderInforesult[1][row_index]), "Product Name doesn't match the selected product name") # Verify the Product Price self.assertTrue(placeorder.check_product_price(product_price), "Product Price doesn't match the selected product") self.assertTrue(placeorder.check_product_price_review(product_price), "Product Price doesn't match the selected product") # Verify the Accessory Message if placeorder.is_accessory_section_exist_checkout_page(): self.assertTrue(placeorder.check_accessory_details(self.OrderInforesult[4][row_index], self.OrderInforesult[9][row_index], accessory_price),"Accessory Text or Accessory Price is not correct") self.assertTrue(placeorder.check_accessory_details_review(self.OrderInforesult[4][row_index], self.OrderInforesult[9][row_index], accessory_price),"Accessory Text or Accessory Price is not correct") # Verify the Notification Message self.assertTrue(placeorder.check_notification_text(self.OrderInforesult[10][row_index]),"Notification Text is not correct") self.assertTrue(placeorder.check_notification_text_review(self.OrderInforesult[10][row_index]),"Notification Text is not correct") # Verify the Price of the product + accessory if requested self.assertTrue(placeorder.check_subtotal(accessory_price, product_price),"Subtotal is not correct") self.assertTrue(placeorder.check_sales_taxes(self.OrderInforesult[11][row_index], product_price), "Sales Tax is not correct") # Verify the Sales Tax on the selected Product self.assertTrue(placeorder.check_sales_taxes_review(self.OrderInforesult[11][row_index], product_price), "Sales Tax is not correct") self.assertTrue(placeorder.check_total_price(self.OrderInforesult[11][row_index], accessory_price, product_price), "Total is not correct") # Verify the Total Price self.assertTrue(placeorder.check_total_price_review(self.OrderInforesult[11][row_index], accessory_price, product_price), "Total is not correct") # Verify the Customer Name ordering the selected Product placeorder.check_name(self.OrderInforesult[2][row_index]) self.assertTrue(placeorder.check_name_review(self.OrderInforesult[2][row_index]), "Customer Name is not correct") # Verify The Phone number of the customer ordering the selected Product placeorder.fill_phone_number(self.OrderInforesult[12][row_index]) self.assertTrue(placeorder.check_phone_number_review(self.OrderInforesult[12][row_index]), "Phone Number doesn't match the entered phone number") # Verify the Address of the Customer ordering the selected Product placeorder.fill_address_optional(self.OrderInforesult[13][row_index], self.OrderInforesult[14][row_index]) self.assertTrue(placeorder.check_address_optional(self.OrderInforesult[13][row_index], self.OrderInforesult[14][row_index]), "Optional Address doesn't match the selected Optional Address") # Verify the Zip Code of the Customer ordering the selected Product placeorder.check_zip_code(self.OrderInforesult[3][row_index]) self.assertTrue(placeorder.check_zip_code_review(self.OrderInforesult[3][row_index]), "Zip Code doesn't match the entered Zip Code") # Verify the details address Line1 of the Customer ordering the selected Product placeorder.fill_address_line1(self.OrderInforesult[15][row_index]) self.assertTrue(placeorder.check_address_line1_review(self.OrderInforesult[15][row_index]), "Address Line 1 doesn't match the entered Address Line 1") # Verify the details address Line2 of the Customer ordering the selected Product placeorder.fill_address_line2(self.OrderInforesult[16][row_index]) self.assertTrue(placeorder.check_address_line2_review(self.OrderInforesult[16][row_index]), "Address Line 2 doesn't match the entered Address Line 2") # Verify the delivery date of the order of the selected Product newdeliveryday = placeorder.fill_delivery_date(self.OrderInforesult[17][row_index]) self.assertTrue(placeorder.check_delivery_date_review(newdeliveryday), "Delivery Date doesn't match the selected Delivery Date") # Verify the first and last name of the recipient of the selected Product placeorder.fill_first_and_last_name(self.OrderInforesult[18][row_index]) self.assertTrue(placeorder.check_first_and_last_name_review(self.OrderInforesult[18][row_index]), "First and last names don't match the entered first and last names") # Verify the Zip Code of the recipient of the selected Product placeorder.fill_billing_zip_code(self.OrderInforesult[19][row_index]) self.assertTrue(placeorder.check_billing_zip_code_review(self.OrderInforesult[19][row_index]), "Billing Zip Code doesn't match the entered billing Zip Code") # Verify the detailed address line 1 of the recipient of the selected Product placeorder.fill_billing_address_l1(self.OrderInforesult[20][row_index]) self.assertTrue(placeorder.check_billing_address_l1(self.OrderInforesult[20][row_index]), "Billing Address Line 1 doesn't match the entered Billing Address Line 1") # Verify the detailed address line 2 of the recipient of the selected Product placeorder.fill_billing_address_l2(self.OrderInforesult[21][row_index]) self.assertTrue(placeorder.check_billing_address_l2(self.OrderInforesult[21][row_index]), "Billing Address Line 2 doesn't match the entered Billing Address Line 2") # Verify the email of the customer ordering the selected Product placeorder.fill_email_address(self.OrderInforesult[22][row_index]) self.assertTrue(placeorder.check_email_address(self.OrderInforesult[22][row_index]), "The email address doesn't match the entered email address") # Verify the phone number of the customer ordering the selected Product placeorder.fill_billing_phone_number(self.OrderInforesult[23][row_index]) self.assertTrue(placeorder.check_billing_phone_number(self.OrderInforesult[23][row_index]), "The Billing Phone number doesn't match the entered Billing Phone number") # Verify if the customer required notification via sms for the order of the selected Product placeorder.check_sms_notification(self.OrderInforesult[24][row_index]) # Verify The creddit card of customer ordering the selected Product placeorder.fill_credit_card_details(self.OrderInforesult[28][row_index], self.OrderInforesult[29][row_index], self.OrderInforesult[30][row_index], self.OrderInforesult[31][row_index]) # Verify if the customer has a promotion code for the order of the selected Product self.assertTrue(placeorder.fill_olyve_premiere_code(self.OrderInforesult[25][row_index], self.OrderInforesult[26][row_index], accessory_price, self.OrderInforesult[11][row_index], product_price, self.OrderInforesult[27][row_index]), "Promotion Code is not applied correctly") # Verify the message sent with the order of the selected Product self.assertTrue(placeorder.check_message_review(self.OrderInforesult[5][row_index]), "The Message doesn't match the entered message") # Verify the signature of the message sent with the order of the selected Product self.assertTrue(placeorder.check_signature_review(self.OrderInforesult[6][row_index]), "The Signature doesn't match the entered signature") # Verify the Video/Photo sent with the order of the selected Product self.assertTrue(placeorder.check_videophoto_review(self.OrderInforesult[8][row_index], self.OrderInforesult[7][row_index], self.GeneralInforesult[1][4]), "The Video/Photo uploaded not found") if self.OrderInforesult[8][row_index] is not None or self.OrderInforesult[7][row_index] is not None: # Returns back to the Checkout Page BasicActions.go_back() placeorder.wait_for_checkout_page() # Click on the Buy button to proceed to the Order Details Page placeorder.Buy_click(self.OrderInforesult[5][row_index]) # Problem in waiting for Order Details Screen, Use time.sleep instead time.sleep(90) if placeorder.wait_for_order_details_page: current_url = Browser._driver.current_url if current_url == self.GeneralInforesult[1][3]: # Check the Order ID placeorder.check_confirmation_number() # Verify the customer name ordering of the selected Product self.assertTrue(placeorder.check_name_order_details(self.OrderInforesult[2][row_index]), "Customer Name is not correct") # Verify the detailed address line 1 of the recipient of the selected Product self.assertTrue(placeorder.check_address_line1_order_details(self.OrderInforesult[15][row_index]), "Address Line 1 doesn't match the entered Address Line 1") # Verify the detailed address line 2 of the recipient of the selected Product self.assertTrue(placeorder.check_address_line2_order_details(self.OrderInforesult[16][row_index]), "Address Line 2 doesn't match the entered Address Line 2") # Verify Zip Code of the the customer ordering of the selected Product self.assertTrue(placeorder.check_zip_code_order_details(self.OrderInforesult[3][row_index]), "Zip Code doesn't match the entered Zip Code") # Verify the Delivery Date of the order self.assertTrue(placeorder.check_delivery_date_order_details(newdeliveryday), "Delivery Date doesn't match the selected Delivery Date") # Verify the Questions and Concerns Contacts for OLYVE self.assertTrue(placeorder.check_questions_and_concerns_oder_details(self.OrderInforesult[32][row_index]), "The number of Questions and Concerns is not correct") # Updates via text using PIN the order if required placeorder.check_updates_via_text_order_details(self.OrderInforesult[33][row_index]) else: raise Exception("Invalid Page") else: raise Exception("Invalid Page") else: raise Exception("Invalid Page")