def test_e2e(self): log = self.getlogger() homepage = Homepage(self.driver) checkoutpage = homepage.shopItems() log.info("getting all the cart titles") product = checkoutpage.productFromList() for item in product: producttext = item.text if producttext == "Blackberry": checkoutpage.getNameFooter().click() checkoutpage.checkoutItems().click() checkoutpage.checkoutConfirmSuccess().click() log.info("Entering country name as Ind") checkoutpage.countrySelectFromList().send_keys("ind") self.verifyLinkPresence("India") checkoutpage.CountrySelectIndia().click() checkoutpage.checkBox().click() checkoutpage.purchase().click() confirmpage = ConfirmPage(self.driver) successmessage = confirmpage.successMessage().text log.info("Text received from application is " + successmessage) assert "Success! Thank you!" in successmessage
def checkStatus(self): hp = Homepage(self.driver) expected_status = "Pending" hp.clickviewRequest() self.driver.find_element_by_xpath("//input[@id='filterInput']").send_keys(self.jobReqNewCard) time.sleep(5) status = self.driver.find_element_by_xpath(self.verifyStatus_xpath).text assert status == expected_status, "Incorrect status, Expected status is %s" %expected_status
def recheckApprovedStatusExistingCard(self): hp = Homepage(self.driver) ExistingCard(self.driver) np = NewCard(self.driver) expected_status = "Approved" hp.clickviewRequest() self.driver.find_element_by_xpath(self.filter_textbox_xpath).send_keys(np.jobReqNewCard) time.sleep(5) status = self.driver.find_element_by_xpath(self.verifyStatus_xpath).text assert status == expected_status, "Incorrect status, Expected status is %s" % expected_status
def approveVoidReq(self, expected_status1, expected_status2): hp = Homepage(self.driver) np = NewCard(self.driver) vp = ViewRequest(self.driver) self.driver.find_element_by_xpath(self.filter_textbox_xpath).send_keys( np.jobReqNewCard) time.sleep(5) self.driver.find_element_by_xpath(self.filter_result_xpath).click() self.driver.find_element_by_xpath(self.approve_button_xpath).click() self.driver.find_element_by_xpath( self.approveConfirmation_xpath).click() time.sleep(5) hp.clickviewVoidRequest() self.driver.find_element_by_xpath(self.filter_textbox_xpath).send_keys( np.jobReqNewCard) time.sleep(5) self.driver.refresh() self.driver.find_element_by_xpath(self.filter_textbox_xpath).send_keys( np.jobReqNewCard) time.sleep(5) status = self.driver.find_element_by_xpath(np.verifyStatus_xpath).text assert status == expected_status1, "Status mismatch! Expected status is %s" % expected_status1 hp.clickutil() hp.clickviewRequest() self.driver.find_element_by_xpath(vp.filter_textbox_xpath).send_keys( np.jobReqNewCard) time.sleep(5) status = self.driver.find_element_by_xpath(np.verifyStatus_xpath).text assert status == expected_status2, "Status mismatch! Expected status is %s" % expected_status2
def viewTopUpRequest(self, rownum): np = NewCard(self.driver) ep = ExistingCard(self.driver) hp = Homepage(self.driver) self.driver.find_element_by_xpath(self.filter_textbox_xpath).send_keys(ep.jobReqExistCard) time.sleep(5) self.driver.find_element_by_xpath(self.filter_result_xpath).click() time.sleep(5) self.driver.find_element_by_xpath(self.approve_button_xpath).click() self.driver.find_element_by_xpath(self.approveConfirmation_xpath).click() time.sleep(5) hp.clickviewRequest() self.driver.find_element_by_xpath(self.filter_textbox_xpath).send_keys(ep.jobReqExistCard) time.sleep(20) self.driver.refresh() self.driver.find_element_by_xpath(self.filter_textbox_xpath).send_keys(ep.jobReqExistCard)
def approveReqExistingCard(self, expected_status): ep = ExistingCard(self.driver) hp = Homepage(self.driver) self.driver.find_element_by_xpath(self.filter_textbox_xpath).send_keys(ep.jobReqExistCard) time.sleep(5) self.driver.find_element_by_xpath(self.filter_result_xpath).click() time.sleep(5) # To approve request for existing card self.driver.find_element_by_xpath(self.approve_button_xpath).click() self.driver.find_element_by_xpath(self.approveConfirmation_xpath).click() hp.clickviewRequest() self.driver.find_element_by_xpath(self.filter_textbox_xpath).send_keys(ep.jobReqExistCard) time.sleep(25) self.driver.refresh() self.driver.find_element_by_xpath(self.filter_textbox_xpath).send_keys(ep.jobReqExistCard) time.sleep(5) status = self.driver.find_element_by_xpath(ep.verifyStatus_xpath).text assert status == expected_status, "Status mismatch! Expected status is %s" % expected_status
def rejectReqNewCard(self, expected_status): np = NewCard(self.driver) hp = Homepage(self.driver) self.driver.find_element_by_xpath(self.filter_textbox_xpath).send_keys(np.jobReqNewCard) time.sleep(5) self.driver.find_element_by_xpath(self.filter_result_xpath).click() time.sleep(5) self.driver.find_element_by_xpath(self.rejectnc_button_xpath).click() self.driver.find_element_by_xpath(self.rejectncReason_xpath).send_keys("Invalid Excel File used") self.driver.find_element_by_xpath(self.reject1_button_xpath).click() self.driver.find_element_by_xpath(self.reject1_button_xpath).click() hp.clickviewRequest() self.driver.find_element_by_xpath(self.filter_textbox_xpath).send_keys(np.jobReqNewCard) time.sleep(25) self.driver.refresh() self.driver.find_element_by_xpath(self.filter_textbox_xpath).send_keys(np.jobReqNewCard) time.sleep(5) status = self.driver.find_element_by_xpath(np.verifyStatus_xpath).text assert status == expected_status, "Status mismatch! Expected status is %s" % expected_status
def rejectReqExistingCard(self, expected_status): ep = ExistingCard(self.driver) hp = Homepage(self.driver) self.driver.find_element_by_xpath(self.filter_textbox_xpath).send_keys(ep.jobReqExistCard) time.sleep(5) self.driver.find_element_by_xpath(self.filter_result_xpath).click() time.sleep(5) self.driver.find_element_by_xpath(self.rejectec_button_xpath).click() self.driver.find_element_by_xpath(self.rejectReason_xpath).send_keys("Invalid request") self.driver.find_element_by_xpath(self.reject1_button_xpath).click() self.driver.find_element_by_xpath(self.reject1_button_xpath).click() time.sleep(5) hp.clickviewRequest() self.driver.find_element_by_xpath(self.filter_textbox_xpath).send_keys(ep.jobReqExistCard) time.sleep(25) self.driver.refresh() self.driver.find_element_by_xpath(self.filter_textbox_xpath).send_keys(ep.jobReqExistCard) time.sleep(5) status = self.driver.find_element_by_xpath(ep.verifyStatus_xpath).text assert status == expected_status, "Status mismatch! Expected status is %s" % expected_status
def test_newcard(self): lp = LoginPage(self.driver) hp = Homepage(self.driver) np = NewCard(self.driver) vp = ViewRequest(self.driver) lp.setUsername(self.username) lp.setPassword(self.password) lp.clickLogin() hp.clickutil() hp.clickreqNewCard() np.createReqNewCard(expected_price=6.00) hp.clickviewRequest() # vp.approveReqNewCard(expected_status="Topup_Completed") vp.rejectReqNewCard(expected_status="Returned")
def rejectVoidReq(self, expected_status3): hp = Homepage(self.driver) np = NewCard(self.driver) self.driver.find_element_by_xpath(self.filter_textbox_xpath).send_keys( np.jobReqNewCard) time.sleep(5) self.driver.find_element_by_xpath(self.filter_result_xpath).click() self.driver.find_element_by_xpath( self.cancelRequest_button_xpath).click() self.driver.find_element_by_xpath( self.cancelRequest_reason_xpath).send_keys( "Top Up Request is valid for Top Up") self.driver.find_element_by_xpath(self.submitReason_xpath).click() self.driver.find_element_by_xpath( self.submitReasonConfirmation_xpath).click() self.driver.find_element_by_xpath(self.closeReason_xpath).click() hp.clickviewVoidRequest() self.driver.find_element_by_xpath(self.filter_textbox_xpath).send_keys( np.jobReqNewCard) time.sleep(5) status = self.driver.find_element_by_xpath(np.verifyStatus_xpath).text assert status == expected_status3, "Status mismatch! Expected status is %s" % expected_status3
def test_viewVoidRequest(self): # To view void top up requests(only applicable to new card) lp = LoginPage(self.driver) hp = Homepage(self.driver) vvp = ViewVoidRequest(self.driver) lp.setUsername(self.username) lp.setPassword(self.password) lp.clickLogin() hp.clickutil() hp.clickviewVoidRequest() vvp.viewVoidRequest()
def test_viewRequest(self): # To view top up requests lp = LoginPage(self.driver) hp = Homepage(self.driver) vp = ViewRequest(self.driver) lp.setUsername(self.username) lp.setPassword(self.password) lp.clickLogin() hp.clickutil() hp.clickviewRequest() vp.viewTopUpRequest(rownum=10)
def test_voidnewcard(self): # This is scenario 1- to create request for new card in tandem with voiding request lp = LoginPage(self.driver) hp = Homepage(self.driver) np = NewCard(self.driver) vp = ViewRequest(self.driver) vvp = ViewVoidRequest(self.driver) lp.setUsername(self.username) lp.setPassword(self.password) lp.clickLogin() hp.clickutil() hp.clickreqNewCard() np.createReqNewCard(expected_price=6.00) hp.clickviewRequest() vp.approveReqNewCard(expected_status="Topup_Completed") vp.createVoidReq() hp.clickutil() hp.clickviewVoidRequest() vvp.approveVoidReq(expected_status1="void_topup_incomplete", expected_status2="Voided")
def test_formSubmission(self, getData): log = self.getlogger() homepage = Homepage(self.driver) log.info("first name is" + (getData["firstname"])) homepage.getName().send_keys(getData["firstname"]) homepage.getEmail().send_keys(getData["email"]) homepage.getcheckBox().click() self.SelectOptionByText(homepage.getGender(), getData["gender"]) homepage.SubmitButton().click() message = homepage.SuccessMessage().text assert ("Success" in message) self.driver.refresh()
def test_FormSubmission(self, getData): log = self.getLogger() home = Homepage(self.driver) log.info("Name: " + getData["name"]) home.getName().send_keys(getData["name"]) log.info("Email: " + getData["email"]) home.getEmail().send_keys(getData["email"]) log.info("Password: "******"password"]) home.getPassword().send_keys(getData["password"]) home.checkIcecream().click() log.info("Gender: " + getData["gender"]) self.SelectOptionByText(home.genderSelection(), getData["gender"]) home.submitButton().click() alert = home.getAlert().text assert "Success!" in alert self.driver.refresh()