def testsavingsaccont(self, web): self.Openbrowser = web self.Openbrowser.get(self.weburl) self.Openbrowser.maximize_window() self.Openbrowser.get(self.weburl) self.refobj = Registration(self.Openbrowser) self.refobj.login(self.username, self.password) filename = self.refobj.accountoverview() time.sleep(3) newaccount = self.refobj.accountcreation("savings", filename) filename = self.refobj.accountoverview() time.sleep(3) self.refobj.logout() rows = xlutils.getrowcount(filename, "Sheet1") for row in range(2, rows): accountnumber = xlutils.readfromxl(filename, "Sheet1", row, 1) #print(accountnumber,newaccount) if newaccount == accountnumber: mark = "sucess" break else: mark = "not found" continue if mark == "sucess": print("Savings account- ", newaccount, " created sucessfully") assert True else: print("failure to create a new account") assert False
def transferaccount(self,filename): self.Openbrowser.find_element_by_xpath(self.linktransfer_xpath).click() time.sleep(3) rows = xlutils.getrowcount(filename,"Sheet1") columns = xlutils.getcolumnount(filename,"Sheet1") sourceaccount = xlutils.readfromxl(filename,"Sheet1",2,1) sourceamount = xlutils.readfromxl(filename,"Sheet1",2,2) sourceamount1 = float(str.replace(sourceamount, '$', '')) targetaccount = xlutils.readfromxl(filename,"Sheet1",3,1) targetaccountamount = xlutils.readfromxl(filename,"Sheet1",3,2) targetaccountamount1 = float(str.replace(targetaccountamount,'$','')) if sourceamount1 >200: self.Openbrowser.find_element_by_xpath(self.inputtransferamount).send_keys("100") select = Select(self.Openbrowser.find_element_by_xpath(self.selectfromaccount_xpath)) select.select_by_visible_text(sourceaccount) select = Select(self.Openbrowser.find_element_by_xpath(self.selecttoaccount_xpath)) select.select_by_visible_text(targetaccount) self.Openbrowser.find_element_by_xpath(self.clicktransferbutton).click() time.sleep(3) msg = self.Openbrowser.find_element_by_xpath("//*[@id='rightPanel']/div/div/h1").text if msg == "Transfer Complete!": print ("$100 transferred from ",sourceaccount," to ",targetaccount) self.logger.info("100 transferred") return True else: print("Transfer failed") self.logger.info("transfer failed") return False else: print("Insufficent balance") self.logger.info("Insufficent funds") return False
def testcheckingaccont(self, browserhandling): self.refobj = Registration(self.Openbrowser) self.refobj.login(self.username, self.password) filename = self.refobj.accountoverview() time.sleep(3) newaccount = self.refobj.accountcreation("checking", filename) filename = self.refobj.accountoverview() time.sleep(3) self.refobj.logout() rows = xlutils.getrowcount(filename, "Sheet1") for row in range(2, rows): accountnumber = xlutils.readfromxl(filename, "Sheet1", row, 1) #print(accountnumber, newaccount) if newaccount == accountnumber: mark = "sucess" break else: mark = "not found" continue if mark == "sucess": print("Checking account- ", newaccount, " created sucessfully") self.logger.info("Checking account created") assert True else: print("failure to create a new account") self.logger("Checking account not created") assert False
def accountcreation(self,type,filename): self.Openbrowser.find_element_by_xpath(self.linkopenaccount_xpath).click() time.sleep(3) select = Select(self.Openbrowser.find_element_by_id(self.selectaccounttype_id)) if type == "checking": select.select_by_visible_text("CHECKING") elif type == "savings": select.select_by_visible_text("SAVINGS") rows =xlutils.getrowcount(filename,"Sheet1") columns = xlutils.getcolumnount(filename,"Sheet1") for row in range(2,rows): Amount = xlutils.readfromxl(filename,"Sheet1",row,2) accountnumber = xlutils.readfromxl(filename,"Sheet1",row,1) amount =float(str.replace(Amount,'$','')) if amount >= 200: select = Select(self.Openbrowser.find_element_by_id(self.fromaccount_id)) select.select_by_visible_text(accountnumber) self.Openbrowser.find_element_by_xpath(self.clickopenaccount_xpath).click() time.sleep(3) newaccountnumber = self.Openbrowser.find_element_by_xpath(self.newaccountid_xpath).text break else: newaccountnumber = 00000 continue return newaccountnumber
# if send_Keys does not work ------------------------------------ dateinputbox_xpath = "//input[@id='datepicker']" month_xpath = "//span[@class='ui-datepicker-month']" year_xpath = "//span[@class='ui-datepicker-year']" leftclick_xpath = "//span[@class='ui-icon ui-icon-circle-triangle-w']" rightclick_xpath = "//span[@class='ui-icon ui-icon-circle-triangle-e']" table_xpath = "//table[@class='ui-datepicker-calendar']" Todaydate = date.today() todaydate = Date_spilt.dateconverter(Todaydate) todaydatestr = str(todaydate) currentyear, currentmonth, currentday = map(int, todaydatestr.split('-')) row = xlutils.getrowcount( "C:\\Users\\Ramya\\PycharmProjects\\demoqa practice\\data\\dates.xlsx", "Sheet1") for r in range(1, row + 1): Inputdate = xlutils.readfromxl( "C:\\Users\\Ramya\\PycharmProjects\\demoqa practice\\data\\dates.xlsx", "Sheet1", r, 1) inputdate = Date_spilt.dateconverter(Inputdate) inputdatestr = str(inputdate) inputyear, inputmonth, inputday = map(int, inputdatestr.split('-')) inputyear = str(inputyear) inputday = str(inputday) inputmonth = Date_spilt.month_numbertostring(inputmonth) if inputdate > todaydate: print("Future date -", inputdate) Openchrome.find_element_by_xpath(dateinputbox_xpath).click() time.sleep(3)