def createCustomer(self): status = 'Fail' ApplicationIndependent.writeLog( "The Create Customer execution is started:" + ApplicationIndependent.getDateTime(), "info") try: self.oBrowser.find_element_by_xpath( "//*[@id='topnav']/tbody/tr[1]/td[3]/a").click() sleep(2) self.oBrowser.find_element_by_xpath( "//*[@id='cpTreeBlock']/div[2]/div[1]/div[2]/div").click() sleep(3) self.oBrowser.find_element_by_xpath( "/html/body/div[12]/div[1]").click() sleep(2) self.oBrowser.find_element_by_xpath( "//*[@id='customerLightBox_nameField']").send_keys( os.environ.get('NewCustomer', -1)) sleep(2) self.oBrowser.find_element_by_xpath( "//*[@id='customerLightBox_descriptionField']").send_keys( os.environ.get('CustomerDiscrption', -1)) sleep(2) self.oBrowser.find_element_by_xpath( "//div[@id='customerLightBox_commitBtn']/div/span[text()= 'Create Customer']" ).click() sleep(3) except Exception as e: ApplicationIndependent.writeLog( "There is an error raised during the execution of the Method createUser,Exception :" + e) ApplicationIndependent.writeLog( "The createUser function has ended execution at :" + ApplicationIndependent.getDateTime(), "info") return status
def modifyCustomer(self): status = 'Fail' ApplicationIndependent.writeLog( "The Created Customer is to be modified:" + ApplicationIndependent.getDateTime(), "info") try: self.oBrowser.find_element_by_xpath( "//table[@class='containerTable']/tbody/tr/td/div/input[@placeholder='Start typing name ...']" ).send_keys(os.environ.get('NewCustomer', -1)) sleep(2) self.oBrowser.find_element_by_xpath( "//div[@class='node customerNode selected']/div[4][@class='editButton available']" ).click() sleep(3) self.oBrowser.find_element_by_xpath( "//div[@class='statusButton']/div/div[@class='active']").click() sleep(3) self.oBrowser.find_element_by_xpath( "//div[@class='dropdownContainer customerStatusMenu active']/div[@class='item archivedContainer']/div" ).click() sleep(3) except Exception as e: ApplicationIndependent.writeLog( "There is an error raised during the execution of the Method createUser,Exception :" + e) ApplicationIndependent.writeLog( "The modifyCustomer function has ended execution at :" + ApplicationIndependent.getDateTime(), "info") return status
def login(self): status = "Fail" ApplicationIndependent.writeLog( "The login function has started execution at :" + ApplicationIndependent.getDateTime(), "info") try: self.oBrowser.find_element_by_id("username").send_keys( os.environ.get('Username', -1)) self.oBrowser.find_element_by_name("pwd").send_keys( os.environ.get('Password', -1)) self.oBrowser.find_element_by_xpath( "//*[@id='loginButton']/div").click() sleep(4) locatorname = "XPATH" locatorvalue = "//td[text()='Enter Time-Track']" if (ApplicationIndependent.isElementPresent(self, locatorname, locatorvalue) == True): status = "Pass" except Exception as e: ApplicationIndependent.writeLog( "There is an error raised during the execution of the Method login,Exception :" + e, "error") ApplicationIndependent.writeLog( "The login function has ended execution at :" + ApplicationIndependent.getDateTime(), "info") return status
def login_button(self): status = "Fail" ApplicationIndependent.writeLog( "The createUser function has started execution at :" + ApplicationIndependent.getDateTime(), "info") try: self.oBrowser.find_element(By.XPATH, Locators.locators.login_button).click() except Exception as e: ApplicationIndependent.writeLog( "There is an error raised during the execution of the Method createUser,Exception :", "error") ApplicationIndependent.writeLog( "The createUser function has ended execution at :" + ApplicationIndependent.getDateTime(), "info")
def LaunchBrowser(self): status = "Fail" ApplicationIndependent.writeLog( "The LaunchBrowser function has started execution at :" + ApplicationIndependent.getDateTime(), "info") try: self.oBrowser = webdriver.Chrome() status = "Pass" self.oBrowser.maximize_window() except Exception: ApplicationIndependent.writeLog( "The Driver Object has not created successfully!!!!", "error") ApplicationIndependent.writeLog( "The LaunchBrowser function has ended execution at :" + ApplicationIndependent.getDateTime(), "info") return status
def closeApplication(self): status = "Fail" ApplicationIndependent.writeLog( "The closeApplication function has started execution at :" + ApplicationIndependent.getDateTime(), "info") try: self.oBrowser.close() status = "Pass" except Exception as e: ApplicationIndependent.writeLog( "There is an error raised during the execution of the Method closeApplication,Exception :", "error") ApplicationIndependent.writeLog( "The closeApplication function has started execution at :" + ApplicationIndependent.getDateTime(), "info") return status
def password(self): status = "Fail" Pass_word = "" ApplicationIndependent.writeLog( "The createUser function has started execution at :" + ApplicationIndependent.getDateTime(), "info") try: Pass_word = self.oBrowser.find_element(By.XPATH, Locators.locators.pass_word) except Exception as e: ApplicationIndependent.writeLog( "There is an error raised during the execution of the Method createUser,Exception :", "error") ApplicationIndependent.writeLog( "The createUser function has ended execution at :" + ApplicationIndependent.getDateTime(), "info") return Pass_word
def deleteCustomer(self): status = 'Fail' ApplicationIndependent.writeLog( "To Delete the customer if it is archived" + ApplicationIndependent.getDateTime(), "info") try: self.oBrowser.find_element_by_xpath( "//table[@class='containerTable']/tbody/tr/td/div/input[@placeholder='Start typing name ...']" ).clear() sleep(2) self.oBrowser.find_element_by_xpath( "//table[@class='containerTable']/tbody/tr/td/div/input[@placeholder='Start typing name ...']" ).send_keys(os.environ.get('NewCustomer', -1)) sleep(2) isarchived = self.oBrowser.find_element_by_xpath( "//*[@id='cpTreeBlock']/div[2]/div[2]/div/div[3]/div/div[1]/div[2]/div[2]/div/span[@class='archived']" ).get_attribute('class') if isarchived == 'archived': # then customer should delete # self.oBrowser.find_element_by_xpath("//*[@id='cpTreeBlock']/div[2]/div[2]/div/div[3]/div/div[1]/div[2]/div[2]/div[4]").click() # sleep(3) self.oBrowser.find_element_by_xpath( "//div[@class='actions']/div/div[@class='actionButton']" ).click() sleep(2) self.oBrowser.find_element_by_xpath( "//div[@class='deleteButton']/div[text()='Delete']").click() sleep(2) self.oBrowser.find_element_by_xpath( "//span[@id='customerPanel_deleteConfirm_submitTitle']").click( ) sleep(3) else: ApplicationIndependent.writeLog( "The customer is not archived, hence could not delete" + ApplicationIndependent.getDateTime() + "info") except Exception as e: ApplicationIndependent.writeLog( "There is an error raised during the execution of the Method Delete Customer,Exception :" + e) ApplicationIndependent.writeLog( "The DeleteCustomer function has ended execution at :" + ApplicationIndependent.getDateTime(), "info") return status
def setUp(self): try: teststarttime = ApplicationIndependent.getDateTime() ReportUtil.createReport(ReportFileName, teststarttime, "QA Testing") except Exception as e: ApplicationIndependent.writeLog( "There is an error raised during the execution of the Method setUp,Exception :" + e, "error")
def navigate(self): status = "Fail" expected = "actiTIME - Login" ApplicationIndependent.writeLog( "The navigate function has started execution at :" + ApplicationIndependent.getDateTime(), "info") try: self.oBrowser.get(os.environ.get('URL', -1)) sleep(2) actual = self.oBrowser.title if (ApplicationIndependent.stringCompare(expected, actual) == True): status = "Pass" except Exception as e: ApplicationIndependent.writeLog( "There is an error raised during the execution of the Method navigate,Exception :", "error") ApplicationIndependent.writeLog( "The navigate function has ended execution at :" + ApplicationIndependent.getDateTime(), "info") return status
def logout(self): status = "Fail" expected = "actiTIME - Login" try: ApplicationIndependent.writeLog( "The logout function has started execution at :" + ApplicationIndependent.getDateTime(), "info") self.oBrowser.find_element_by_link_text("Logout").click() sleep(4) actual = self.oBrowser.title if (ApplicationIndependent.stringCompare(expected, actual) == True): status = "Pass" except Exception as e: ApplicationIndependent.writeLog( "There is an error raised during the execution of the Method logout,Exception :" + e, "error") ApplicationIndependent.writeLog( "The logout function has ended execution at :" + ApplicationIndependent.getDateTime(), "info") return status
def testRunner(self): startTime = ApplicationIndependent.getDateTime() ReportUtil.startSuite("Scenario", ReportFileName) ControllerFileName = "E:/PYTHON/Browser Drivers/Final_Automation_FW/Controller/data_Controller.xlsx" rc = Datatable.getRowCount(ControllerFileName, "Scenarios") print("# of tests in data_Controller.xlsx File ....", rc) for r in range(rc): testcaseid = Datatable.getCellData(ControllerFileName, "Scenarios", "TestcaseID", r) testcasename = Datatable.getCellData(ControllerFileName, "Scenarios", "TestcaseName", r) testdesc = Datatable.getCellData(ControllerFileName, "Scenarios", "Description", r) runStatus = Datatable.getCellData(ControllerFileName, "Scenarios", "RunStatus", r) print("testcaseid :" + testcaseid) print("testcasename :" + testcasename) print("testdesc :" + testdesc) print("runStatus :" + runStatus) if (runStatus.lower() == 'yes'): testfilename = testcasename + ".xlsx" # print(testfilename) testscenarioFile = "E:/PYTHON/Browser Drivers/Final_Automation_FW/TestScriptDataFiles/" + testfilename print(testscenarioFile) scenariorowcount = Datatable.getRowCount( testscenarioFile, testcaseid) methods = [] listtestscriptid = [] listtsdescription = [] liststatus = [] listscreenshot = [] for tsid in range(scenariorowcount - 1): testscriptid = Datatable.getCellData( testscenarioFile, testcaseid, "TestScriptID", tsid + 1) tsdescription = Datatable.getCellData( testscenarioFile, testcaseid, "Description", tsid + 1) tsmethodname = Datatable.getCellData( testscenarioFile, testcaseid, "MethodName", tsid + 1) print("testscriptid :" + testscriptid) print("tsdescription :" + tsdescription) print("tsmethodname :" + tsmethodname) listtestscriptid.append(testscriptid) listtsdescription.append(tsdescription) methods.append(tsmethodname) Datatable.loadTestDataInEnvironmentVariable( testscenarioFile, "testdata") print(methods) for method in methods: resultStatus = eval(method) liststatus.append(resultStatus) if (resultStatus == "Fail"): pass #ScreenshorPath=Configuration.ScreenshotPath+"" #ScreenshorName = ScreenshorPath + "ScreenShot_" + testcasename + "_" + testscriptid + "_" + method + ".jpg"; #listscreenshot.append(ScreenshorName) #ApplicationIndependent.captureScreenShot(ScreenshorName) else: listscreenshot.append("") ApplicationIndependent.writeLog( "The Execution status of method " + method + " from Scenario " + testcasename + " :" + str(resultStatus), "info") endTime = ApplicationIndependent.getDateTime() detailResultFileName = ReportUtil.writeDeatilTestResults( testcasename, listtestscriptid, listtsdescription, methods, liststatus, listscreenshot) print(detailResultFileName) if 'Fail' in liststatus: ReportUtil.writeSummaryTestResults(ReportFileName, detailResultFileName, testcaseid, testcasename, "Failed", startTime, endTime) else: ReportUtil.writeSummaryTestResults(ReportFileName, detailResultFileName, testcaseid, testcasename, "Passed", startTime, endTime) ApplicationIndependent.writeLog( "+++++++++++++++++++++++++++++++++++++", "info")
def deleteUser(self): status="Fail" ApplicationIndependent.writeLog("The deleteUser function has started execution at :" + ApplicationIndependent.getDateTime(), "info") try: username = os.environ.get('LastName', -1) + ", " + os.environ.get('FirstName', -1) sleep(2) print(username) self.oBrowser.find_element_by_xpath("//span[text()=\'" + username + "\']").click() sleep(2) self.oBrowser.find_element_by_id("userDataLightBox_deleteBtn").click() sleep(2) if (ApplicationIndependent.isAlertPresent(self)==True): status="Pass" self.oBrowser.switch_to.alert.accept() sleep(2) except Exception as e: ApplicationIndependent.writeLog("There is an error raised during the execution of the Method deleteUser,Exception :" + e) ApplicationIndependent.writeLog("The deleteUser function has ended execution at :" + ApplicationIndependent.getDateTime(), "info") return status
def modifyUser(self): status="Fail" expected="actiTIME - User List" ApplicationIndependent.writeLog("The modifyUser function has started execution at :" + ApplicationIndependent.getDateTime(), "info") try: username = os.environ.get('LastName', -1) + ", " + os.environ.get('FirstName', -1) sleep(2) self.oBrowser.find_element_by_xpath("//span[text()=\'" + username + "\']").click() sleep(2) self.oBrowser.find_element_by_name("password").send_keys(os.environ.get('UserNewPassword', -1)) sleep(2) self.oBrowser.find_element_by_name("passwordCopy").send_keys(os.environ.get('UserRetypeNewPassword', -1)) sleep(3) self.oBrowser.find_element_by_xpath("//span[text()='Save Changes']").click() sleep(5) actual = self.oBrowser.title print(actual) if (ApplicationIndependent.stringCompare(expected, actual) == True): status = "Pass" except Exception as e: ApplicationIndependent.writeLog("There is an error raised during the execution of the Method modifyUser,Exception :" + e) ApplicationIndependent.writeLog("The modifyUser function has ended execution at :" + ApplicationIndependent.getDateTime(), "info") return status
def createUser(self): status="Fail" ApplicationIndependent.writeLog("The createUser function has started execution at :" + ApplicationIndependent.getDateTime(), "info") try: self.oBrowser.find_element_by_xpath("//*[@id='topnav']/tbody/tr[1]/td[5]/a/div[2]").click() sleep(3) #self.oBrowser.find_element_by_id("gettingStartedShortcutsPanelId").click() #sleep(2) self.oBrowser.find_element_by_xpath("//div[text()='Add User']").click() sleep(2) self.oBrowser.find_element_by_name("firstName").send_keys(os.environ.get('FirstName', -1)) sleep(1) self.oBrowser.find_element_by_name("lastName").send_keys(os.environ.get('LastName', -1)) sleep(1) self.oBrowser.find_element_by_name("email").send_keys(os.environ.get('Email', -1)) sleep(1) self.oBrowser.find_element_by_name("username").send_keys(os.environ.get('UserUsername', -1)) sleep(1) self.oBrowser.find_element_by_name("password").send_keys(os.environ.get('UserPassword', -1)) sleep(1) self.oBrowser.find_element_by_name("passwordCopy").send_keys(os.environ.get('UserRetypePassword', -1)) sleep(1) self.oBrowser.find_element_by_xpath("//span[text()='Create User']").click() sleep(4) username = os.environ.get('LastName', -1) + ", " + os.environ.get('FirstName', -1) sleep(2) locatorname="XPATH" locatorvalue="//span[text()=\'" + username + "\']" if (ApplicationIndependent.isElementPresent(self,locatorname,locatorvalue)==True): status="Pass" except Exception as e: ApplicationIndependent.writeLog("There is an error raised during the execution of the Method createUser,Exception :" + e) ApplicationIndependent.writeLog("The createUser function has ended execution at :" + ApplicationIndependent.getDateTime(), "info") return status