def test_carryout_delivery_pizza_select_api(self, driver): navigate_to_select_pizza(driver) coupon = "//*[contains(@class,'media--coupon--featured-image')]" Keywords.ClickElement(driver, coupon) close = "//*[contains(@class,'js-closeButton')]" Keywords.ClickElement(driver, close) couponError = "//*[@class='couponHeader__text']" error = "COUPON INCOMPLETE" assert (Keywords.getText(driver, couponError) == error ), "Coupon error not displayed when empty order"
def test_delivery_address_ui_component(self,driver): navigate_to_dominos(driver) delivery_button="//*[contains(@class,'js-delivery')]" Keywords.ClickElement(driver, delivery_button) deliveryRadio="//*[@name='Service_Type'][contains(@value,'Delivery')]" Keywords.isElementSelected(driver, deliveryRadio) addressPath="//*[@id='Address_Type_Select']/option[contains(text(),'House')]" Keywords.ClickElement(driver, addressPath) street_address="//*[@name='Street']" randomStreet=Keywords.generateRandom('letter','digits','punctuation',20) Keywords.enterText(driver,randomStreet,street_address) Keywords.WebElement(driver,street_address).send_keys(Keys.TAB) assert (Keywords.getAttributeValue(driver,street_address)==randomStreet),"Street address not entered correctly" address_line2="//*[@name='Address_Line_2']" randomAddressLine2=Keywords.generateRandom('letter','digits','punctuation',10) Keywords.enterText(driver,randomAddressLine2,address_line2) Keywords.WebElement(driver,address_line2).send_keys(Keys.TAB) assert (Keywords.getAttributeValue(driver,address_line2)==randomAddressLine2),"Street address 2 not entered correctly" city="//*[@name='City']" randomCity=Keywords.generateRandom('letter','digits','punctuation',20) Keywords.enterText(driver,randomCity,city) Keywords.WebElement(driver,city).send_keys(Keys.TAB) assert (Keywords.getAttributeValue(driver,city)==randomCity),"City is not entered correctly" state="//*[@name='Region']" Keywords.ClickElement(driver,state) state_AZ="//*[@name='Region']/option[contains(text(),'AZ')]" Keywords.ClickElement(driver,state_AZ) zip_code="//*[@name='Postal_Code']" randomZip=Keywords.generateRandom('letter','digits','punctuation',20) Keywords.enterText(driver,randomZip,zip_code) Keywords.WebElement(driver,zip_code).send_keys(Keys.TAB) assert (Keywords.getAttributeValue(driver,zip_code)!=randomZip),"Zip Code entered with Alphabets and Punctuation"
def fill_form(driver): firstName="//*[@id='First_Name']" fName="Anvesh" Keywords.enterText(driver,fName,firstName) #Value not populated in the HTML page and not able to Assert if the text has been entered #assert (Keywords.getAttributeValue(driver,firstName)==fName),"First Name Not entered correctly" lastName="//*[@id='Last_Name']" lName="Malhotra" Keywords.enterText(driver,lName,lastName) Keywords.WebElement(driver,lastName).send_keys(Keys.TAB) #Value not populated in the HTML page and not able to Assert if the text has been entered #assert (Keywords.getAttributeValue(driver,lastName)==lName),"Last Name not entered correctly" email="//*[@id='Email']" emailAddress="*****@*****.**" Keywords.enterText(driver,emailAddress,email) Keywords.WebElement(driver,email).send_keys(Keys.TAB) #Value not populated in the HTML page and not able to Assert if the text has been entered #assert (Keywords.getAttributeValue(driver,email)==emailAddress),"Email Addres not entered correctly" callbackPhone="//*[@id='Callback_Phone']" phone="1234567890" Keywords.enterText(driver,phone,callbackPhone) Keywords.WebElement(driver,callbackPhone).send_keys(Keys.TAB) #Value not populated in the HTML page and not able to Assert if the text has been entered #assert (Keywords.getAttributeValue(driver,callbackPhone)==phone),"Phone not entered correctly" payAtStore="//*[contains(@class,'c-order-payment-cash')]" Keywords.ClickElement(driver,payAtStore) assert (Keywords.isElementSelected(driver,payAtStore)==True),"payment not selected correctly"
def test_carryout_address_unit(self,driver): navigate_to_dominos(driver) carryout_button="//*[contains(@class,'js-carryout')]" Keywords.ClickElement(driver, carryout_button) carryoutRadio="//*[@name='Service_Type'][contains(@value,'Carryout')]" assert (Keywords.isElementSelected(driver, carryoutRadio) is True), "Carryout Icon is not selected" zip_code="//*[@name='Postal_Code']" assert (Keywords.getType(driver, zip_code)=="tel"),"Attribute for Zip Code is incorrect" assert (Keywords.getAttributeLength(driver,zip_code)=='10'),"Max Length for Zip Code is incorrect" zip_code="//*[@for='Postal_Code']" assert(Keywords.getText(driver, zip_code)=="*Zip Code:"),"Zip Code doesn't match" toggleZip="//*[contains(@class,'toggle-zip')]/a" if(len(driver.find_elements_by_xpath((toggleZip)))>0): Keywords.ClickElement(driver,toggleZip) state_values=['Select', 'AK', 'AL', 'AR', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL', 'GA', 'HI', 'IA', 'ID', 'IL', 'IN', 'KS', 'KY', 'LA', 'MA', 'MD', 'ME', 'MI', 'MN', 'MO', 'MS', 'MT', 'NC', 'ND', 'NE', 'NH', 'NJ', 'NM', 'NV', 'NY', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY'] state="//*[@id='Region']" Keywords.ClickElement(driver,state) states=state+"/option" stateElements=Keywords.WebElements(driver,states) statesList=[] for state in stateElements: statesList.append(state.text) for state in state_values: assert(state in statesList),"State not available in list: %s"%state city="//*[@name='City']" assert (Keywords.getType(driver, city)=="text"),"Attribute for city is incorrect" assert (Keywords.getAttributeLength(driver,city)=='40'),"Max Length for city is incorrect" city="//*[@for='City']" assert(Keywords.getText(driver, city)=="*City:"),"City text doesn't match" state="//*[@for='Region']" assert(Keywords.getText(driver, state)=="*State:"),"State doesn't match"
def test_delivery_carryout_payment_api(self,driver): navigate_to_payment(driver) placeOrder="//*[contains(@class,'js-placeOrder')]" Keywords.ClickElement(driver,placeOrder) error="This field is required." errorLocation=["//*[@id='First_Name-error']","//*[@id='Last_Name-error']","//*[@id='Email-error']", "//*[@id='Callback_Phone-error']","//*[@id='Payment_Type-error']" ] for path in errorLocation: assert(Keywords.getText(driver,path)==error),"Error not populated for path %s"%path
def test_e2e_carryout_dominos(self,driver): navigate_to_select_pizza(driver) specialityPizza="//*[contains(@class,'order-entrees-specialtypizza')]/h2" Keywords.ClickElement(driver,specialityPizza) order="//*[contains(@data-dpz-track-evt-name,'Order')]" orderElements=Keywords.WebElements(driver,order) numberOfPizza=2 count=0 for element in orderElements: if(count<numberOfPizza): element.click() addToOrder="//*[@type='submit'][contains(text(),'No, Add to Order Now')]" Keywords.ClickElement(driver,addToOrder) Keywords.isElementVisible(driver,order) count+=1 cart="//*[@class='order-summary__item__title']/a" cartElements=Keywords.WebElements(driver,cart) assert (len(cartElements)==numberOfPizza),"Cart Not updated with the number of pizza's added" checkout="//*[contains(@class,'order-buttonCheckout-text')]" Keywords.ClickElement(driver,checkout) overlay="//*[@class='card--overlay__close js-closeButton']" if(len(driver.find_elements_by_xpath(overlay))>0): Keywords.ClickElement(driver,overlay) reviewOrder="//*[@class='card__title__icon'][contains(text(),'Review Order Settings')]" Keywords.isElementVisible(driver,reviewOrder) visible=len(driver.find_elements_by_xpath(reviewOrder)) assert (visible>0),"Page not navigated after selecting pizza" continueCheckOut="//*[contains(@class,'js-continueCheckout')]" Keywords.ClickElement(driver,continueCheckOut) fill_form(driver) #placeOrder="//*[contains(@class,'submitButton')]" #Keywords.ClickElement(driver,placeOrder)
def test_carryout_address_ui_component(self,driver): navigate_to_dominos(driver) carryout_button="//*[contains(@class,'js-carryout')]" Keywords.ClickElement(driver, carryout_button) carryoutRadio="//*[@name='Service_Type'][contains(@value,'Carryout')]" Keywords.isElementSelected(driver, carryoutRadio) zip_code="//*[@name='Postal_Code']" randomZip=Keywords.generateRandom('letter','digits','punctuation',20) Keywords.enterText(driver,randomZip,zip_code) Keywords.WebElement(driver,zip_code).send_keys(Keys.TAB) assert (Keywords.getAttributeValue(driver,zip_code)!=randomZip),"Zip Code entered with Alphabets and Punctuation" toggleZip="//*[contains(@class,'toggle-zip')]/a" if(len(driver.find_elements_by_xpath((toggleZip)))>0): driver.find_element_by_xpath(toggleZip).click() city="//*[@name='City']" randomCity=Keywords.generateRandom('letter','digits','punctuation',20) Keywords.enterText(driver,randomCity,city) Keywords.WebElement(driver,city).send_keys(Keys.TAB) assert (Keywords.getAttributeValue(driver,city)==randomCity),"City is not entered correctly" state="//*[@name='Region']" Keywords.ClickElement(driver,state) state_AZ="//*[@name='Region']/option[contains(text(),'AZ')]" Keywords.ClickElement(driver,state_AZ)
def test_carryout_address_api(self,driver): navigate_to_dominos(driver) carryout_button="//*[contains(@class,'js-carryout')]" Keywords.ClickElement(driver, carryout_button) carryoutRadio="//*[@name='Service_Type'][contains(@value,'Carryout')]" Keywords.isElementSelected(driver, carryoutRadio) toggleZip="//*[contains(@class,'toggle-zip')]/a" if(len(driver.find_elements_by_xpath((toggleZip)))>0): Keywords.ClickElement(driver,toggleZip) submit="//*[contains(@class,'js-search-cta')]" Keywords.ClickElement(driver, submit) error="This field is required." city_error="//*[@id='City-error']" assert (Keywords.getText(driver, city_error)==error), "City Error is not the same as expected" state_error="//*[@id='Region-error']" assert (Keywords.getText(driver, state_error)==error),"State Error is not the same as expected" postal_code_error="//*[@id='Postal_Code-error']" assert (Keywords.getText(driver, postal_code_error)==error),"Zip Code Error is not the same as expected"
def test_delivery_address_api(self,driver): navigate_to_dominos(driver) delivery_button="//*[contains(@class,'js-delivery')]" Keywords.ClickElement(driver, delivery_button) deliveryRadio="//*[@name='Service_Type'][contains(@value,'Delivery')]" Keywords.isElementSelected(driver, deliveryRadio) addressPath="//*[@id='Address_Type_Select']/option[contains(text(),'House')]" Keywords.ClickElement(driver, addressPath) submit="//*[contains(@class,'js-search-cta')]" Keywords.ClickElement(driver, submit) error="This field is required." state_error="//*[@id='Region-error']" assert (Keywords.getText(driver, state_error)==error),"State Error is not the same as expected: %s for %s" %(error,add) postal_code_error="//*[@id='Postal_Code-error']" assert (Keywords.getText(driver, postal_code_error)==error),"Zip Code Error is not the same as expected: %s for %s" %(error,add) city_error="//*[@id='City-error']" assert (Keywords.getText(driver, city_error)==error), "City Error is not the same as expected: %s for %s" %(error,add) street_error="//*[@id='Street-error']" assert (Keywords.getText(driver, street_error)==error),"Street Error is not the same as expected: %s for %s" % (error,add)
def navigate_to_payment(driver): navigate_to_select_pizza(driver) specialityPizza="//*[contains(@class,'order-entrees-specialtypizza')]/h2" Keywords.ClickElement(driver,specialityPizza) order="//*[contains(@data-dpz-track-evt-name,'Order')]" orderElements=Keywords.WebElements(driver,order) numberOfPizza=1 count=0 for element in orderElements: if(count<numberOfPizza): element.click() addToOrder="//*[@type='submit'][contains(text(),'No, Add to Order Now')]" Keywords.ClickElement(driver,addToOrder) Keywords.isElementVisible(driver,order) count+=1 checkout="//*[contains(@class,'order-buttonCheckout-text')]" Keywords.ClickElement(driver,checkout) overlay="//*[@class='card--overlay__close js-closeButton']" if(len(driver.find_elements_by_xpath(overlay))>0): Keywords.ClickElement(driver,overlay) continueCheckout="//*[contains(@class,'js-continueCheckout')]" Keywords.ClickElement(driver,continueCheckout)
def test_carryout_delivery_pizza_ui_component_checkout(self, driver): navigate_to_select_pizza(driver) specialityPizza = "//*[contains(@class,'order-entrees-specialtypizza')]/h2" Keywords.ClickElement(driver, specialityPizza) order = "//*[contains(@data-dpz-track-evt-name,'Order')]" orderElements = Keywords.WebElements(driver, order) numberOfPizza = 2 count = 0 for element in orderElements: if (count < numberOfPizza): element.click() addToOrder = "//*[@type='submit'][contains(text(),'No, Add to Order Now')]" Keywords.ClickElement(driver, addToOrder) Keywords.isElementVisible(driver, order) count += 1 cart = "//*[@class='order-summary__item__title']/a" cartElements = Keywords.WebElements(driver, cart) assert (len(cartElements) == numberOfPizza ), "Cart Not updated with the number of pizza's added" #Remove Item from cart remove = "//*[contains(@class,'js-removeVariant')]" Keywords.ClickElement(driver, remove) updatedPizzaNumber = numberOfPizza - 1 newCart = "//*[@class='order-summary__item__title']/a" newCartElements = Keywords.WebElements(driver, newCart) #Assertion if the item has been removed assert ( len(newCartElements) == updatedPizzaNumber ), "Cart Not updated with the number of pizza's added after deletion" #Change the quantity quantity = "//*[@aria-label='Quantity:']" Keywords.ClickElement(driver, quantity) selectQuantity = quantity + "/option[2]" Keywords.ClickElement(driver, selectQuantity) checkout = "//*[contains(@class,'order-buttonCheckout-text')]" Keywords.ClickElement(driver, checkout) overlay = "//*[@class='card--overlay__close js-closeButton']" if (len(driver.find_elements_by_xpath(overlay)) > 0): Keywords.ClickElement(driver, overlay) reviewOrder = "//*[@class='card__title__icon'][contains(text(),'Review Order Settings')]" Keywords.isElementVisible(driver, reviewOrder) visible = len(driver.find_elements_by_xpath(reviewOrder)) assert (visible > 0), "Page not navigated after selecting pizza"
def navigate_to_select_pizza(driver): #Get to the pizza select page navigate_to_dominos(driver) delivery_button = "//*[contains(@class,'js-delivery')]" Keywords.ClickElement(driver, delivery_button) deliveryRadio = "//*[@name='Service_Type'][contains(@value,'Delivery')]" Keywords.isElementVisible(driver, deliveryRadio) zip_code = "//*[@name='Postal_Code']" zip_codeValue = "85281" Keywords.enterText(driver, "85281", zip_code) # toggleZip="//*[contains(@class,'toggle-zip')]/a" # if(len(driver.find_elements_by_xpath((toggleZip)))>0): # driver.find_element_by_xpath(toggleZip).click() city = "//*[@name='City']" cityValue = "TEMPE" Keywords.enterText(driver, cityValue, city) state = "//*[@name='Region']" Keywords.ClickElement(driver, state) state_AZ = "//*[@name='Region']/option[contains(text(),'AZ')]" stateValue = "AZ" Keywords.ClickElement(driver, state_AZ) addressPath = "//*[@id='Address_Type_Select']/option[contains(text(),'House')]" Keywords.ClickElement(driver, addressPath) street_address = "//*[@name='Street']" randomStreet = "1215 E Vista Del Cerro Drive" Keywords.enterText(driver, randomStreet, street_address) address_line2 = "//*[@name='Address_Line_2']" randomAddressLine2 = "Apartment 1016S" Keywords.enterText(driver, randomAddressLine2, address_line2) submit = "//*[@type='submit']" Keywords.ClickElement(driver, submit) if (len(driver.find_elements_by_xpath("//*[@class='based-on']")) > 0): orderCarryOutLocation = "//*[contains(@class,'search-results-list')]/div/div[1]/div/a" Keywords.ClickElement(driver, orderCarryOutLocation) changeOrderTimingOverlay = "//*[@id='changeOrderTimingOverlay']/div/form//div/select" if (len(driver.find_elements_by_xpath(changeOrderTimingOverlay)) > 0): Keywords.ClickElement(changeOrderTimingOverlay) selectTime = changeOrderTimingOverlay + "/option[3]" Keywords.ClickElement(selectTime) awaitingOrder = "//*[contains(@class,'js-emptyMessage')]" Keywords.isElementVisible(driver, awaitingOrder)
def test_carryout_button(self, driver): navigate_to_dominos(driver) carryout_button = "//*[contains(@class,'js-carryout')]" button_text = Keywords.getText(driver, carryout_button) assert ( button_text == 'CARRYOUT' ), "Text of Carryout Button is incorrect, expected: %s" % 'CARRYOUT' assert (Keywords.isElementEnabled(driver, carryout_button) is True), "Deliver Button is not enabled" Keywords.ClickElement(driver, carryout_button) try: Keywords.isElementVisible(driver, "//*[@class='form']/div/div/h2/span") finally: assert ( driver.title == "Location Search - Location Search" ), "After Delivery Button is clicked either page not visible or wrong page"
def navigate_to_select_pizza(driver): #Get to the pizza select page navigate_to_dominos(driver) carryout_button = "//*[contains(@class,'js-carryout')]" Keywords.ClickElement(driver, carryout_button) carryoutRadio = "//*[@name='Service_Type'][contains(@value,'Carryout')]" Keywords.isElementVisible(driver, carryoutRadio) zip_code = "//*[@name='Postal_Code']" zip_codeValue = "85281" Keywords.enterText(driver, "85281", zip_code) toggleZip = "//*[contains(@class,'toggle-zip')]/a" if (len(driver.find_elements_by_xpath((toggleZip))) > 0): driver.find_element_by_xpath(toggleZip).click() city = "//*[@name='City']" cityValue = "TEMPE" Keywords.enterText(driver, cityValue, city) state = "//*[@name='Region']" Keywords.ClickElement(driver, state) state_AZ = "//*[@name='Region']/option[contains(text(),'AZ')]" stateValue = "AZ" Keywords.ClickElement(driver, state_AZ) submit = "//*[@type='submit']" Keywords.ClickElement(driver, submit) Keywords.isElementVisible(driver, "//*[@class='based-on']") orderCarryOutLocation = "//*[contains(@class,'search-results-list')]/div/div[1]/div/a" Keywords.ClickElement(driver, orderCarryOutLocation) changeOrderTimingOverlay = "//*[@id='changeOrderTimingOverlay']/div/form//div/select" if (len(driver.find_elements_by_xpath(changeOrderTimingOverlay)) > 0): Keywords.ClickElement(changeOrderTimingOverlay) selectTime = changeOrderTimingOverlay + "/option[3]" Keywords.ClickElement(selectTime) awaitingOrder = "//*[contains(@class,'js-emptyMessage')]" Keywords.isElementVisible(driver, awaitingOrder)
def test_delivery_address_unit(self,driver): navigate_to_dominos(driver) delivery_button="//*[contains(@class,'js-delivery')]" Keywords.ClickElement(driver, delivery_button) deliveryRadio="//*[@name='Service_Type'][contains(@value,'Delivery')]" assert (Keywords.isElementSelected(driver, deliveryRadio) is True), "Delivery Icon is not selected" addressPath="//*[@id='Address_Type_Select']/option[contains(text(),'House')]" Keywords.ClickElement(driver, addressPath) types_of_address=['Apartment','Business','Campus/Base','Hotel','Dormitory','Other','House'] address="//*[@id='Address_Type_Select']/option" assert (Keywords.isElementVisible(driver, address) is True),"Address is not available for selection" addressList=Keywords.WebElements(driver, address) address_values=[] for add in addressList: address_values.append(add.text) for add in types_of_address: assert(add in address_values),"Address not available in list: %s"%add street_address="//*[@name='Street']" assert (Keywords.getType(driver, street_address)=="text"),"Attribute for address is incorrect, expected :%s for %s"%("text",'House') assert (Keywords.getAttributeLength(driver, street_address)=='40'),"Max Length for address is incorrect, expected:%s for %s"%('40','House') address_line2="//*[@name='Address_Line_2']" assert (Keywords.getType(driver, address_line2)=="text"),"Attribute for Address Line 2 is incorrect,expected: %s for %s" %("text",'House') assert (Keywords.getAttributeLength(driver,address_line2)=='40'),"Max Length for Address Line 2 is incorrect, expected:%s for %s" % ('40','House') city="//*[@name='City']" assert (Keywords.getType(driver, city)=="text"),"Attribute for city is incorrect, expected :%s for %s"%("text",'House') assert (Keywords.getAttributeLength(driver,city)=='40'),"Max Length for city is incorrect, expected:%s for %s" % ('40','House') zip_code="//*[@name='Postal_Code']" assert (Keywords.getType(driver, zip_code)=="tel"),"Attribute for Zip Code is incorrect,expected: %s for %s"%("tel",'House') assert (Keywords.getAttributeLength(driver,zip_code)=='10'),"Max Length for Zip Code is incorrect, expected:%s for %s" % ('10','House') Keywords.ClickElement(driver, "//*[@id='Address_Type_Select']/option") states="//*[@name='Region']/option" state_values=['Select', 'AK', 'AL', 'AR', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL', 'GA', 'HI', 'IA', 'ID', 'IL', 'IN', 'KS', 'KY', 'LA', 'MA', 'MD', 'ME', 'MI', 'MN', 'MO', 'MS', 'MT', 'NC', 'ND', 'NE', 'NH', 'NJ', 'NM', 'NV', 'NY', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY'] statesElements=Keywords.WebElements(driver, states) statesList=[] for state in statesElements: statesList.append(state.text) for state in state_values: assert(state in statesList),"State not available in list: %s"%state address_type="//*[contains(@class,'js-otherAddress')]/div[1]/label" assert(Keywords.getText(driver, address_type)=="Address Type:"),"Text for Address Type doesn't match Address Type: 'House'" street_address="//*[@for='Street']" assert(Keywords.getText(driver, street_address)=="*Street Address:"),"Street address text does't match for address type: 'House'" city="//*[@for='City']" assert(Keywords.getText(driver, city)=="*City:"),"City text doesn't match for address type: 'House'" state="//*[@for='Region']" assert(Keywords.getText(driver, state)=="*State:"),"State doesn't match for address type: 'House'" zip_code="//*[@for='Postal_Code']" assert(Keywords.getText(driver, zip_code)=="*Zip Code:"),"Zip Code doesn't match for address type: 'House'" address_line2="//*[@for='Address_Line_2']" assert(Keywords.getText(driver, address_line2)=="Suite/Apt #"),"Suite/Apt# text doesn't match expected: %s for %s" % ("Suite/Apt #",add)