Ejemplo n.º 1
0
 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")
Ejemplo n.º 2
0
 def tearDown(self):
     try:
         # Clear all Environment Variables
         os.environ.clear()
         ReportUtil.endSuite(ReportFileName)
     except Exception as e:
         ApplicationIndependent.writeLog(
             "There is an error raised during the execution of the Method tearDown,Exception :"
             + e, "error")
Ejemplo n.º 3
0
def endSuite(ReportFileName):
    try:
        file = open(ReportFileName, "a")
        file.write("</table>")
        file.close()
    except Exception as e:
        ApplicationIndependent.writeLog(
            "There is an error raised during the execution of the Method endSuite,Exception :"
            + e, "error")
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
def createReport(FileName, teststarttime, environment):
    try:
        ReportFileName = FileName
        ReportDirectorypath = Configuration.ReportPath

        file = open(FileName, "w")
        file.write("<html>")
        file.write("<head><title>ActiTime Automation Results</title></head>")
        file.write("<body>")
        file.write("<h1 align=center>ActiTime Automation Results</h1>")
        file.write("<table border=2>")
        file.write("<h3>Automation Summary</h3>")
        file.write("<tr>")
        file.write("<th align=center>Item Name</th>")
        file.write("<th align=center>Item Value</th>")
        file.write("</tr>")
        file.write("<tr>")
        file.write("<td>Application Name</td>")
        file.write("<td>" + Configuration.applicationname + "</td>")
        file.write("</tr>")
        file.write("<tr>")
        file.write("<td>Application Version</td>")
        file.write("<td>" + Configuration.applicationversion + "</td>")
        file.write("</tr>")
        file.write("<tr>")
        file.write("<td>Browser Name</td>")
        file.write("<td>" + Configuration.browserName + "</td>")
        file.write("</tr>")
        file.write("<tr>")
        file.write("<td>Application URL</td>")
        file.write("<td>" + Configuration.url + "</td>")
        file.write("</tr>")
        file.write("<tr>")
        file.write("<td>Environment</td>")
        file.write("<td>" + environment + "</td>")
        file.write("</tr>")
        file.write("<tr>")
        file.write("<td>Automation Start Time</td>")
        file.write("<td>" + teststarttime + "</td>")
        file.write("</tr>")
        file.write("<tr>")
        file.write("<td>Automation End Time</td>")
        file.write("<td>END_TIME</td>")
        file.write("</tr>")
        file.write("</table>")
        file.write("</body>")
        file.write("</html>")
        file.close()
    except Exception as e:
        ApplicationIndependent.writeLog(
            "There is an error raised during the execution of the Method createReport,Exception :"
            + e, "error")
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
def writeDeatilTestResults(testscenarioname, listtestscriptid,
                           listtsdescription, methods, listStatus,
                           listScreenShot):
    try:
        ReportDirectorypath = Configuration.ReportPath
        FileName = ReportDirectorypath + "Scenario" + "_" + testscenarioname + "_Results.html"
        #print(FileName)
        file = open(FileName, "w")

        file.write("<html>")
        file.write("<head><title>" + testscenarioname +
                   " Detail Results</title></head>")
        file.write("<body>")
        file.write("<h1 align=center>" + testscenarioname +
                   " Detail Results</h1>")
        file.write("<table border=1 width=100%>")
        file.write("<h2 align=left>" + testscenarioname +
                   " Detail Results</h2>")
        file.write("<tr>")
        file.write("<th width=15%>TestScriptID</th>")
        file.write("<th width=20%>Description</th>")
        file.write("<th width=25%>TestScriptName</th>")
        file.write("<th width=15%>Status</th>")
        file.write("<th width=25%>ScreenShotName</th>")
        file.write("</tr>")
        for i in range(len(methods)):
            file.write("<tr>")
            file.write("<td width=10%>" + listtestscriptid[i] + "</td>")
            file.write("<td width=20%>" + listtsdescription[i] + "</td>")
            file.write("<td width=15%>" + methods[i] + "</td>")
            if (str(listStatus[i]).lower() == "pass"):
                file.write("<td width=10%>" + listStatus[i] + "</td>")
                file.write("<td width=25%>&nbsp</td>")
            else:
                file.write("<td width=10%>" + listStatus[i] + "</td>")
                file.write("<td width=25%><a href=file:///" +
                           listScreenShot[i] + ".jpg" +
                           ">ScreenShotName</a></td>")
            file.write("</tr>")

        file.write("</table>")
        file.write("</body>")
        file.write("</html>")
        file.close()

    except Exception as e:
        ApplicationIndependent.writeLog(
            "There is an error raised during the execution of the Method writeDeatilTestResults,Exception :"
            + e, "error")
    return FileName
Ejemplo n.º 8
0
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
Ejemplo n.º 9
0
def writeSummaryTestResults(mainReportFileName, detailFileName, testcaseid,
                            testname, status, starttime, endtime):
    try:
        file = open(mainReportFileName, "a")
        file.write("<tr>")
        file.write("<td width=15% align=center>" + testcaseid + "</td>")
        file.write("<td width=20% align=center>" + testname + "</td>")
        file.write("<td width=15% align=center><a href=file:///" +
                   detailFileName + ">" + status + "</a></td>")
        file.write("<td width=25% align=center>" + starttime + "</td>")
        file.write("<td width=25% align=center>" + endtime + "</td>")
        file.write("</tr>")
    except Exception as e1:
        ApplicationIndependent.writeLog(
            "There is an error raised during the execution of the Method writeTestResults,Exception :"
            + e1, "error")
Ejemplo n.º 10
0
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
Ejemplo n.º 11
0
def startSuite(ScenarioName, ReportFileName):

    try:
        strScenarioName = str(ScenarioName).replace(" ", "_")
        file = open(ReportFileName, "a")
        file.write("<html>")
        file.write("<body>")
        file.write("<table width=100% border=2>")
        file.write("<h2>Automation Execution Details</h2>")
        file.write("<tr>")
        file.write("<th align=center width=15%>Testcase ID</th>")
        file.write("<th align=center width=20%>Testcase Name</th>")
        file.write("<th align=center width=15%>Status</th>")
        file.write("<th align=center width=25%>Test Start Time</th>")
        file.write("<th align=center width=25%>Test End Time</th>")
        file.write("</tr>")
        file.close()
    except Exception as e:
        ApplicationIndependent.writeLog(
            "There is an error raised during the execution of the Method startSuite,Exception :"
            + e, "error")
Ejemplo n.º 12
0
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")
Ejemplo n.º 13
0
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
Ejemplo n.º 14
0
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
Ejemplo n.º 15
0
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
Ejemplo n.º 16
0
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
Ejemplo n.º 17
0
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
Ejemplo n.º 18
0
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
Ejemplo n.º 19
0
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
Ejemplo n.º 20
0
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
Ejemplo n.º 21
0
    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")