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 test_shop_button_second_slide_click(self):
     homepage = HomePage(Browser._driver)
     selected_slide = homepage.click_on_second_slide()
     if homepage.verify_slide_is_active(selected_slide)== True:
         homepage.shop_button_second_slide_click()
         BasicActions.implicit_wait(40)
         # Switch to the newly opened window
         Browser._driver.switch_to.window(Browser._driver.window_handles[1])
         # Make sure the newly opened window is loaded in order to get the URL
         if homepage.wait_for_instgram_page_load():
             url_name = Browser._driver.current_url
             # Verify that the URL of the newly opened page is the URL of Olyve Instgram Social Link
             self.assertEqual(self.Homeresult[1][7], Browser._driver.current_url, "Error in asserting the Instgram link")
    def test_go_to_product(self):
        homepage = HomePage(Browser._driver)

        # Get the number of products
        for Index in range(0, homepage.get_product_count()):
            homepage.findproductandclick(Index)
            BasicActions.implicit_wait(20)
            # Wait for Product Page to load
            if homepage.wait_for_product_page():
                url_name = BasicActions.get_current_url()
                url_name_from_excel = self.Productresult[1][Index]
                self.assertEqual(url_name, url_name_from_excel)
            BasicActions.go_back()
            BasicActions.refresh_page()
            BasicActions.implicit_wait(5)
 def test_twitter_social_info(self):
     try:
         # Instance from homepage class
         homepage = HomePage(Browser._driver)
         # Wait till home page is loaded before clicking on Twitter link
         if homepage.wait_for_product_image_load():
             # Call the twitter_social_info function
             homepage.twitter_social_info()
             # Wait till home page is loaded after clicking on Twitter link
             BasicActions.implicit_wait(20)
             # Switch to the newly opened window
             Browser._driver.switch_to.window(Browser._driver.window_handles[1])
             # Make sure the newly opened window is loaded in order to get the URL
             if homepage.wait_for_twitter_page_load:
                 url_name = Browser._driver.current_url
                 # Verify that the URL of the newly opened page is the URL of Olyve Twitter Social Link
                 self.assertEqual(self.Homeresult[1][9], Browser._driver.current_url, "Error in asserting the Twitter link")
     except:
         raise Exception("Twitter link not correct")
    def test_navigating_between_products_slide(self):
        try:

            homepage = HomePage(Browser._driver)
            selected_slide = homepage.click_on_second_slide()
            self.assertTrue(homepage.verify_slide_is_active(selected_slide), "Second Slide is not active")

            BasicActions.implicit_wait(20)
            selected_slide = homepage.click_on_third_slide()
            self.assertTrue(homepage.verify_slide_is_active(selected_slide), "Third Slide is not active")

            BasicActions.implicit_wait(30)
            selected_slide = homepage.click_on_first_slide()
            BasicActions.implicit_wait(5)
            self.assertTrue(homepage.verify_slide_is_active(selected_slide), "First Slide is not active")

        except:
            raise Exception("There is an issue in navigating between the slides")
 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")