Exemple #1
0
 def AttachFile(self, fileName, locatorType, locator):
     global objActions
     objActions = PerformActions()
     strFilePath = os.path.join(os.path.dirname(
         os.getcwd())) + '\\Attachments\\' + fileName + '.xlsx'.strip()
     if Path(strFilePath).is_file():
         objActions.enterText(locatorType, locator, strFilePath)
         time.sleep(2)
         print("FIle uploaded sucessfully")
     else:
         print("could not find the file to uplaod")
Exemple #2
0
class Filter():
    global objCommon, objActions, objConfig
    objCommon = CommonFunctions()
    objActions = PerformActions()
    objConfig=MyConfigFiles()

    def ClickCreate(self):
        objActions.clickElement(QET.Create_button_xpath, "xpath")

# Method to navigate to the screen from login page
    def NavigateToSCAR(self, ScarID):
        objActions.clickElement(QET.SCARs_link_xpath, "xpath")
        objActions.clickElement("//a[text()='" + ScarID + "']", "xpath")
        time.sleep(2)

# Method to navigate to the screen from login page
    def NavigateToQIP(self, QIPID):
        objActions.clickElement(QET.QIPs_link_xpath, "xpath")
        objActions.clickElement("//a[text()='" + QIPID + "']", "xpath")
        time.sleep(2)


# Method to navigate to the screen from login page
    def NavigateToQI(self, QIID):
        objActions.clickElement(QET.QIs_link_xpath, "xpath")
        objActions.clickElement("//a[text()='" + QIID + "']", "xpath")
        time.sleep(2)
Exemple #3
0
 def capture_screenshot(self, FileName):
     time.sleep(2)
     ScreenShot_ReportFile_Path = os.path.join(
         os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
         "TestReport\\")
     TCname = os.environ.get('PYTEST_CURRENT_TEST').split(':')[-1].split(
         ' ')[0].replace('test_', "")
     # caller function and its module name
     Appname = TCname.split('_')[1] + "_Module"
     WorkingDirectory = os.path.join(
         ScreenShot_ReportFile_Path, 'ScreenShots', Appname,
         TCname)  # Create target Directory if don't exist
     PerformActions.createdirectory(WorkingDirectory)
     strTime = time.asctime().split(' ')
     MyConfigFiles.driver.get_screenshot_as_file(
         WorkingDirectory + '/' + strTime[3].replace(':', '') + '_' +
         FileName + '.png')
Exemple #4
0
class login_Page():
    global objCommon, objActions, objPCN
    objCommon = CommonFunctions()
    objActions = PerformActions()

    def PCN_Login(self, UserName, Password):
        objActions.enterText(PCN.username_textbox_id, "id", UserName)
        objActions.enterText(PCN.password_textbox_id, "id", Password)
        objActions.clickElement(PCN.submit_button_xpath, "xpath")
        objCommon.capture_screenshot('Login Page Successfull')

    def PCN_LogOut(self):
        objActions.clickElement(PCN.logout_link_xpath, "xpath")
class SwitchToRoles_Page():
    global objCommon, objActions, objConfig, objHome, objFilter
    objCommon = CommonFunctions()
    objActions = PerformActions()
    objConfig = MyConfigFiles()
    objFilter = Filter()
    objHome = Home()

    #Role Types Available[Context CE, Global Commodity Manager, NPI Material PM, NPI MPM]
    def SwitchToRole(self, roleType):
        time.sleep(3)
        objHome.ClickSwitchRolesLnk()
        time.sleep(2)
        objActions.clickElement(PCN.Submit_SR_button_xpath, "xpath")
        objActions.clickElement("//span[text()='" + roleType + "']/input",
                                "xpath")
        print("Sucessfully selected the role: " + roleType)
        objCommon.capture_screenshot("Role Selected")
        objActions.clickElement(PCN.Submit_SR_button_xpath, "xpath")
class CompleteAssessment_Page():
    global objCommon, objActions ,objConfig,objFilter,objHome,objCreateJPCN,objJPCNStatusOverview
    objCommon = CommonFunctions()
    objActions = PerformActions()
    objConfig=MyConfigFiles()
    objFilter=Filter()
    objHome=Home()
    objCreateJPCN = createJPCN_Page()
    objJPCNStatusOverview=JPCNstatusoverview_Page()



    def Verify_CompleteAssessment(self,strJPNID):
        time.sleep(2)
        objActions.clickElement(PCN.DashBoard_ContextCE_CompleteAssessment_WebElement_xapth, "xpath")
        objJPCNStatusOverview.SelectJCPN(strJPNID)
        objCommon.capture_screenshot("Completed Assessment page display")
        strPageHeader=objActions.getText(PCN.Completed_Assessement_PageHeader_WebElement_xpath, "xpath")
        assert (objActions.getText(PCN.Completed_Assessement_PageHeader_WebElement_xpath, "xpath"))
        print("Completed Assessment page displayed Sucessfully:"  +strPageHeader )
Exemple #7
0
class Home():
    global objCommon, objActions, objConfig
    objCommon = CommonFunctions()
    objActions = PerformActions()
    objConfig = MyConfigFiles()

    def ClickSwitchRolesLnk(self):
        objActions.clickElement(PCN.Switch_Roles_link_xpath, "xpath")

    def DashboardLnk(self):
        objActions.clickElement(PCN.DashBoard_Button_xpath, "xpath")

    def ClickAdminlnk(self):
        objActions.clickElement(PCN.Admin_link_xpath, "xpath")

    def ClickReportsLnk(self):
        objActions.clickElement(PCN.Reports_link_xpath, "xpath")

    def ClickSearchLnk(self):
        objActions.clickElement(PCN.Search_link_xpath, "xpath")
Exemple #8
0
class ClosureAssessment_Page():
    global objCommon, objActions, objConfig, objFilter, objHome, objCreateJPCN
    objCommon = CommonFunctions()
    objActions = PerformActions()
    objConfig = MyConfigFiles()
    objFilter = Filter()
    objHome = Home()
    objCreateJPCN = createJPCN_Page()

    def Closure_Assesement_DashBorad_Link(self):
        time.sleep(2)
        objActions.clickElement(
            PCN.DashBoard_ContextCE_ClosureAssessment_WebElement_xapth,
            "xpath")
        time.sleep(3)
        objCommon.capture_screenshot("Closure Assessment  Page intiiated")

    def ValidationcheckFor_JPNMPNInfor_Section(self):
        objCreateJPCN.ClickOnJPN_MPN_Exapnd()
        time.sleep(3)
        global flag
        time.sleep(2)
        strPages = objActions.getText(PCN.ContextCE_TablePage_Count_xpath,
                                      "xpath")
        strPagesCount = strPages.split(" ")
        intPagesCount = int(strPagesCount[4])
        flag = False
        for pages in range(1, intPagesCount + 1):
            objTable = MyConfigFiles.driver.find_elements_by_xpath(
                "//table[@id='upload-jpn']/tbody/tr")
            intRowCount = len(objTable)
            for i in range(2, intRowCount + 1):
                stri = str(i)
                objTablecol = MyConfigFiles.driver.find_elements_by_xpath(
                    "//table[@id='upload-jpn']/tbody/tr/th")
                intColCount = len(objTablecol)
                for j in range(i, intColCount + 1):
                    strj = str(j)
                    strchoosefile = objActions.getText(
                        "//table[@id='upload-jpn']/tbody/tr[" + stri +
                        "]/td[2]", "xpath")
                    if strchoosefile == "MAXIM":
                        time.sleep(2)
                        objActions.clickElement(
                            "//table[@id='upload-jpn']/tbody/tr[" + stri +
                            "]/td[2]//a[1]", "xpath")
                        time.sleep(2)
                        LTB_Decision = MyConfigFiles.driver.find_element_by_xpath(
                            "//div[contains(@class,'supplier-info-section padding-around show-it')]//select[@id='selectDrpDwn']"
                        )
                        LTB_DStatus = LTB_Decision.is_enabled()
                        LTB_Comments = MyConfigFiles.driver.find_element_by_xpath(
                            "//tr[8]//td[2]//div[1]//div[1]//div[1]//input[1]")
                        LTB_CStatus = LTB_Comments.is_enabled()
                        if (LTB_DStatus) and (LTB_CStatus) == True:
                            print("LTB Decision and Comments are  Editable")
                            objActions.selectDropdown(
                                "//div[contains(@class,'supplier-info-section padding-around show-it')]//select[@id='selectDrpDwn']",
                                "xpath", "visibletext", "Bridge Buy")
                            time.sleep(3)
                            objActions.enterText(
                                "//tr[8]//td[2]//div[1]//div[1]//div[1]//input[1]",
                                "xpath", "Comments")
                            time.sleep(3)
                            objCommon.capture_screenshot(
                                "LTB Decision and LTB comments sucessfully edited and saved"
                            )
                            objActions.clickElement(PCN.Submit_SR_button_xpath,
                                                    "xpath")
                            time.sleep(3)
                        else:
                            print("LTB Decision and Comments are not Editable")
                            objCommon.capture_screenshot(
                                "LTB Decision and Comments are not Editable")
                            time.sleep(3)
                            objActions.clickElement(PCN.Cancel_Button_xpath,
                                                    "xpath")
                            flag = True
                            break

    def ValidationcheckFor_CONTEXTCE_DETAILS_Section_ClosureAssessment(
            self, PCNStatus):
        time.sleep(2)
        objActions.selectDropdown(PCN.Validate_PCNStatus_Value_name, "name",
                                  "visibletext", PCNStatus)
        html = MyConfigFiles.driver.find_element_by_tag_name('html')
        html.send_keys(Keys.TAB)
        time.sleep(2)
        strIPCNS_Act = objActions.getText(
            PCN.Validation_msg_ClosureAssesment_WebElement_xapth, "xpath")
        time.sleep(2)
        strIPCNS_Exp = "Invalid pcn status"
        if strIPCNS_Act == strIPCNS_Exp:
            print("Passed - Validation Message is dispalying as::"
                  " " + strIPCNS_Act)
        else:
            print("Failed -NO validation message is displayed")
        assert strIPCNS_Act == strIPCNS_Exp

    def Fill_CONTEXTCE_Drtails_Section_ClosureAssessment(
            self, PCNStatus, pcnComments, pcnClosedComments):
        time.sleep(2)
        objActions.selectDropdown(PCN.Validate_PCNStatus_Value_name, "name",
                                  "visibletext", PCNStatus)
        time.sleep(3)
        objActions.enterText(PCN.Validate_PCNStatusComment_Value_name, "name",
                             pcnComments)
        time.sleep(3)
        objActions.enterText(PCN.PCNStatusClose_Comments_name, "name",
                             pcnClosedComments)
        time.sleep(3)
        objActions.clickElement(PCN.Close_Assessment_WebElement_xpath, "xpath")
        # Waring_Msg=objActions.getText(PCN.Close_Assessment_Warning_WebElement_xpath, "xpath")
        # print(Waring_Msg)
        # assert (objActions.AssertObjectExists(PCN.Close_Assessment_Warning_WebElement_xpath, "xpath"))

    def EDit_PR_Section_ClosureAssessment(self, PCNStatus, pcnComments,
                                          pcnClosedComments):
        time.sleep(3)
        global flag
        time.sleep(4)
        objTable = MyConfigFiles.driver.find_elements_by_xpath(
            "//div[@class='context-ce-details-section padding-around show-it']//div[@class='inline']//div//table[@id='pr']/tbody/tr"
        )
        intRowCount = len(objTable)
        for i in range(2, intRowCount + 1):
            stri = str(i)
            strEcoMcoStatus = objActions.getText(
                "//div[@class='context-ce-details-section padding-around show-it']//div[@class='inline']//div//table[@id='pr']/tbody/tr["
                + stri + "]/td[7]", "xpath")
            if strEcoMcoStatus != '':
                objActions.clickElement(
                    "//div[@class='context-ce-details-section padding-around show-it']//div[@class='inline']//div//table[@id='pr']/tbody/tr["
                    + stri + "]/td[1]", "xpath")
                time.sleep(2)
                MyConfigFiles.driver.find_element_by_name("mcoEco").clear()
                objActions.enterText(PCN.AddNewRecord_ECOMCO_WebEdit_name,
                                     "name", "Invailddata")
                objCommon.capture_screenshot(
                    "MCOECO Values is edited Sucessfully with invalid data")
                objActions.clickElement(PCN.AddNewAttachement_SubmitBtn_xpath,
                                        "xpath")
                time.sleep(1)
                objActions.selectDropdown(PCN.Validate_PCNStatus_Value_name,
                                          "name", "visibletext", PCNStatus)
                time.sleep(2)
                objActions.enterText(PCN.Validate_PCNStatusComment_Value_name,
                                     "name", pcnComments)
                time.sleep(2)
                objActions.enterText(PCN.PCNStatusClose_Comments_name, "name",
                                     pcnClosedComments)
                time.sleep(2)
                objActions.clickElement(PCN.Close_Assessment_WebElement_xpath,
                                        "xpath")
                Waring_Msg = objActions.getText(
                    PCN.Close_Assessment_Warning_WebElement_xpath, "xpath")
                print(Waring_Msg)
                assert (objActions.AssertObjectExists(
                    PCN.Close_Assessment_Warning_WebElement_xpath, "xpath"))
                objActions.clickElement(PCN.Completed_Page_OK_button_xpath,
                                        "xpath")
                time.sleep(2)
                objActions.clickElement(
                    "//div[@class='context-ce-details-section padding-around show-it']//div[@class='inline']//div//table[@id='pr']/tbody/tr["
                    + stri + "]/td[1]", "xpath")
                time.sleep(2)
                MyConfigFiles.driver.find_element_by_name("mcoEco").clear()
                objActions.clickElement(PCN.AddNewAttachement_SubmitBtn_xpath,
                                        "xpath")
                time.sleep(2)
                objActions.clickElement(PCN.Close_Assessment_WebElement_xpath,
                                        "xpath")
            break
class JPCNstatusoverview_Page():
    global objCommon, objActions, objConfig, objFilter, objHome
    objCommon = CommonFunctions()
    objActions = PerformActions()
    objConfig = MyConfigFiles()
    objFilter = Filter()
    objHome = Home()

    def ClickContextCE_Create_Items(self):
        time.sleep(2)
        objActions.clickElement(PCN.DashBoard_CreateItem_WebElement_xpath,
                                "xpath")
        objCommon.capture_screenshot('Clicked on Create Item Sections')

    def ClickContextCE_InitialAssessment_Items(self):
        time.sleep(2)
        objActions.clickElement(
            PCN.DashBoard_InitialAssessment_WebElement_xpath, "xpath")
        objCommon.capture_screenshot('Clicked on InitialAssessment Sections')

    def ClickDashboard_Link(self):
        time.sleep(3)
        html = MyConfigFiles.driver.find_element_by_tag_name('html')
        html.send_keys(Keys.PAGE_UP)
        time.sleep(2)
        objActions.clickElement(PCN.DashBoard_Button_xpath, "xpath")
        assert (objActions.AssertObjectExists(PCN.DashBoard_Button_xpath,
                                              "xpath"))
        print("Dashboard link clicked sucessfully")

    def ClickCoreCE_AssesmnetPending_Items(self):
        time.sleep(2)
        objActions.clickElement(
            PCN.DashBoard_CoreCEAssessment_WebElement_xpath, "xpath")
        objCommon.capture_screenshot(
            'Clicked on CoreCE Assessment Item Sections')
        time.sleep(3)

    def SelectJCPN(self, JCPNInput):
        global flag
        time.sleep(2)
        # self.ClickContextCE_Create_Items()
        strPages = objActions.getText(PCN.ContextCE_TablePage_Count_xpath,
                                      "xpath")
        strPagesCount = strPages.split(" ")
        intPagesCount = int(strPagesCount[4])
        if intPagesCount <= 1:
            time.sleep(30)
        # print("Number of pages displayed: "+str(intPagesCount))
        flag = False
        for pages in range(1, intPagesCount + 1):
            objTable = MyConfigFiles.driver.find_elements_by_xpath(
                "//table[@id='created-jpcn']/tbody/tr")
            intRowCount = len(objTable)
            # print("Rows Count in page "+str(pages)+" is: "+str(intRowCount-1))
            for i in range(2, intRowCount + 1):
                stri = str(i)
                strJCPN = objActions.getText(
                    "//table[@id='created-jpcn']/tbody/tr[" + stri + "]/td[2]",
                    "xpath")
                # print(strJCPN)
                if strJCPN == JCPNInput:
                    time.sleep(2)
                    objActions.clickElement(
                        "//table[@id='created-jpcn']/tbody/tr[" + stri +
                        "]/td[2]", "xpath")
                    flag = True
                    # print("JPCN is displayed on Page: "+str(pages))
                    break
                    time.sleep(10)
            if flag == True:
                break
            else:
                time.sleep(3)
                objActions.clickElement("//a[text()='" + str(pages + 1) + "']",
                                        "xpath")
                time.sleep(4)
        if flag == False:
            sys.exit("FAILED:: Could not find the JPCNNumber: " + JCPNInput)

    def SendBack_with_AssignBacktoContextCE(self, AssginbackComments):
        time.sleep(2)
        objActions.clickElement(PCN.JPCNStatus_Overivew_Button_xpath, "xpath")
        time.sleep(3)
        objActions.enterText(PCN.AssignBack_Comments_WebEdit_xpath, "xpath",
                             AssginbackComments)
        time.sleep(2)
        assert (objActions.AssertObjectExists(PCN.submit_button_xpath,
                                              "xpath"))
        objActions.clickElement(PCN.submit_button_xpath, "xpath")
        objCommon.capture_screenshot("Sendback to Context CE")

    def Reassign_Assessment(self):
        time.sleep(2)
        objActions.clickElement(
            PCN.DashBoard_ReassignAssessment_WebElement_xpath, "xpath")

    def Validation_OnCoreCE_ManadtoryFields(self, strFilePath, QRAS, QRRC,
                                            CoreCERecommendations,
                                            CoreCeREComments, ReasonforNC):
        time.sleep(2)
        # objCommon.AttachFile(strFilePath, PCN.QualDataReview_CoreCE_Attachement_xpath, "xpath")
        # time.sleep(3)
        # objActions.clickElement(PCN.QualDateReview_CoreCe_Upload_xpath, "xpath")
        # time.sleep(4)
        time.sleep(2)
        objActions.selectDropdown(PCN.QualReport_AcceptStaus_CoreCE_xpath,
                                  "xpath", "visibletext", QRAS)
        time.sleep(3)
        objActions.enterText(PCN.QualReport_ReviewComments_CoreCE_xpath,
                             "xpath", QRRC)
        time.sleep(2)
        objActions.selectDropdown(PCN.CoreCe_Recommendation_name, "name",
                                  "visibletext", CoreCERecommendations)
        time.sleep(2)
        objActions.enterText(PCN.CoreCe_Recommendation_comments_name, "name",
                             CoreCeREComments)
        time.sleep(3)
        self.CoreCE_PCN_ChangeComplianceSelect_Validations(ReasonforNC)
        time.sleep(2)
        strMsg1 = objActions.getText(PCN.CoreCE_ChangeStatus_xapth, "xpath")
        strMsg2 = objActions.getText(PCN.CoreCE_Gobackmsg_xpath, "xpath")
        strValidationMsg = strMsg1 + strMsg2
        time.sleep(2)
        print("Display Validations message" + strValidationMsg)
        time.sleep(2)

    def Goabck_button(self):
        time.sleep(3)
        objActions.clickElement(PCN.Goback_Button_xpath, "xpath")
        time.sleep(3)
        # self.CoreCE_PCN_ChangeComplianceSelect_Validations(ReasonforNC)

    def Submit_CoreCE_Assessment(self):
        objActions.clickElement(PCN.submit_button_xpath, "xpath")
        time.sleep(3)
        objActions.clickElement(
            PCN.DashBoard_CoreCECompAssessment_WebElement_xpath, "xpath")
        time.sleep(3)
        self.SelectJCPN()
        time.sleep(3)
        JPCNStatus = objActions.getText(PCN.JPCN_Analyis_Stage_Status_xpath,
                                        "xpath")
        print("JPCN Analyis stage is completed sucessfully" + JPCNStatus)
        objCommon.capture_screenshot("JPCN Closed sucessfully")

    def CoreCE_PCN_ChangeComplianceSelect_Validations(self, ReasonforNC):
        time.sleep(3)
        # strPCNComplience = objActions.getText(PCN.PCNCompliance_CoreCE_SelectBox_xpath, "xpath")
        strPCNComplience = objActions.ValidationOnSelectedtext(
            PCN.Compliance_CoreCE_SelectBox_xpath, "xpath")
        print(strPCNComplience)
        time.sleep(2)
        if strPCNComplience == "Compliant":
            time.sleep(2)
            objActions.selectDropdown(PCN.Compliance_CoreCE_SelectBox_xpath,
                                      "xpath", "visibletext", "Non-Compliant")
            time.sleep(2)
            objActions.selectDropdown(
                PCN.PCNReason_NonCompliance_CoreCE_SelectBox_xpath, "xpath",
                "visibletext", ReasonforNC)
        else:
            time.sleep(2)
            objActions.selectDropdown(PCN.Compliance_CoreCE_SelectBox_xpath,
                                      "xpath", "visibletext", "Compliant")
            time.sleep(2)
            objActions.enterText(PCN.CoreCE_Justifications_name, "name",
                                 "Justificaion")
            time.sleep(3)
        objActions.clickElement(PCN.Complete_Assessment_Button_xpath, "xpath")
Exemple #10
0
class InitilaAssessment_Page():
    global objCommon, objActions, objConfig, objHome, objFilter
    objCommon = CommonFunctions()
    objActions = PerformActions()
    objConfig = MyConfigFiles()
    objFilter = Filter()
    objHome = Home()

    def InitialAssessment_ContextCE_Details(self, CCER, priorityType, CCERC,
                                            PCNTYPE, ASQNeeded, ASQNComments):
        time.sleep(2)
        objActions.selectDropdown(PCN.ContextCE_Recommendation_SelectBox_name,
                                  "name", "visibletext", CCER)
        time.sleep(2)
        objActions.enterText(PCN.ContextCE_RecommendationComments_WebEdit_name,
                             "name", CCERC)
        objActions.selectDropdown(PCN.Priority_Type_selectBox_name, "name",
                                  "visibletext", priorityType)
        time.sleep(2)
        if PCNTYPE == 'EOL':
            time.sleep(2)
            objActions.selectDropdown(
                PCN.IA_Alternative_SourceQN_SelectBox_name, "name",
                "visibletext", ASQNeeded)
            time.sleep(2)
            objActions.enterText(
                PCN.IA_FFF_Alternative_SourceComments_WedEdit_name, "name",
                ASQNComments)
        #    assert PCNTYPE == 'EOL'
        # else:
        #     print("PCNType is not EOL"+PCNTYPE)

    def InitialAssessment_AddNewRecord(self, PR, Deviation, DeviationStatus,
                                       Seventeneleveen, JPN, MPN, HTR, MCOECO,
                                       QPET, Comments, JuniperAssembly):
        objActions.clickElement(PCN.IA_AddNewRecord_WebElement_xpath, "xpath")
        time.sleep(2)
        objActions.enterText(PCN.AddNewRecord_PR_WebEdit_name, "name", PR)
        objActions.enterText(PCN.AddNewReocrd_Deviation_WebEdit_name, "name",
                             Deviation)
        objActions.selectDropdown(
            PCN.AddNewRecord_DeviationStatus_selectBox_name, "name",
            "visibletext", DeviationStatus)
        time.sleep(3)
        objActions.enterText(PCN.AddNewRecord_710_711_WebEdit_name, "name",
                             Seventeneleveen)
        objActions.enterText(PCN.AddNewRecord_JPN_WebEdit_name, "name", JPN)
        objActions.enterText(PCN.AddNewRecord_MPN_WebEdit_name, "name", MPN)
        objActions.enterText(PCN.AddNewRecord_HTR_WebEdit_name, "name", HTR)
        time.sleep(2)
        objActions.enterText(PCN.AddNewRecord_ECOMCO_WebEdit_name, "name",
                             MCOECO)
        # objActions.enterText(PCN.AddNewRecord_ECOMCO_Status_WebEdit_name, "name", MCOECOStatus)
        objActions.enterText(PCN.AddNewRecord_qpet_WebEdit_name, "name", QPET)
        time.sleep(2)
        objActions.enterText(PCN.AddNewRecord_Comment_WebEdit_name, "name",
                             Comments)
        objActions.enterText(PCN.AddNewRecord_JA_WebEdit_name, "name",
                             JuniperAssembly)
        time.sleep(3)
        objActions.clickElement(PCN.AddNewAttachement_SubmitBtn_xpath, "xpath")

    def QualDataReview_Attachement(self, strFilePath, QualReportStatus,
                                   QualReportComments):
        time.sleep(2)
        objCommon.AttachFile(strFilePath, PCN.QualDataReview_Attachement_xpath,
                             "xpath")
        objActions.clickElement(PCN.QualDataReview_Upload_xpath, "xpath")
        time.sleep(3)
        objActions.selectDropdown(PCN.QualReport_AcceptStaus_name, "name",
                                  "visibletext", QualReportStatus)
        time.sleep(3)
        objActions.enterText(PCN.QualReport_ReviewComments_name, "name",
                             QualReportComments)
        time.sleep(2)

    def Complete_Assessment(self):
        time.sleep(2)
        objActions.clickElement(PCN.Complete_Assessment_Button_xpath, "xpath")
        time.sleep(2)

    def Submit_OnWarringWindow(self):
        time.sleep(2)
        objActions.clickElement(PCN.submit_button_xpath, "xpath")
        time.sleep(2)

    def InitialAssessment_Checking_AutoPopulationOfPCNCompliance(
            self, PCNTYPE, intEFRCDiff, intBRDiff, intSBDiff, ReasonforNC):
        time.sleep(2)
        objActions.ValidationOnSelectedtext(
            PCN.IA_PCNCompliance_SelectBox_name, "name")
        if (PCNTYPE == ('Process Change' or 'Design Change')):
            strPCNComplience = objActions.ValidationOnSelectedtext(
                PCN.IA_PCNCompliance_SelectBox_name, "name")
            if intEFRCDiff >= 90:
                if strPCNComplience == "Compliant":
                    print(
                        "Where:" + PCNTYPE +
                        "and Effective and Received date >=90 then PCN Compliance is Autopopulates to :"
                        " " + strPCNComplience)
                    objCommon.capture_screenshot(
                        "PCN Compliance as: Compliant ")
                else:
                    print("PCNComplience dropdown displaying as :"
                          " " + strPCNComplience + "insted of : Compliant")
                    assert strPCNComplience == "Compliant"
            elif intEFRCDiff < 90:
                if strPCNComplience == "Non-Compliant":
                    time.sleep(2)
                    objActions.selectDropdown(
                        PCN.Reasonfor_NonCompliance_SelectBox_name, "name",
                        "visibletext", ReasonforNC)
                    time.sleep(2)
                    print(
                        "Where:" + PCNTYPE +
                        "and Effective and Received date < 90 then PCN Compliance is Autopopulates to :"
                        " " + strPCNComplience)
                    objCommon.capture_screenshot(
                        "PCN Compliance as: Non-Compliant ")
                else:
                    print("PCNComplience dropdown displaying as :"
                          " " + strPCNComplience + "insted of: Non-Compliant ")
                    assert strPCNComplience == "Non-Compliant"
        elif PCNTYPE == 'EOL':
            strPCNComplience = objActions.ValidationOnSelectedtext(
                PCN.IA_PCNCompliance_SelectBox_name, "name")
            if intBRDiff >= 180:
                if strPCNComplience == "Compliant":
                    print(
                        "Where:" + PCNTYPE +
                        "and Effective and Received date >=180 then PCN Compliance is Autopopulates to :"
                        " " + strPCNComplience)
                    objCommon.capture_screenshot(
                        "PCN Compliance as: Compliant ")
                else:
                    print("PCNComplience dropdown displaying as :"
                          " " + strPCNComplience + "insted of : Compliant")
                    assert strPCNComplience == "Compliant"
            elif intBRDiff < 180:
                if strPCNComplience == "Non-Compliant":
                    time.sleep(2)
                    objActions.selectDropdown(
                        PCN.Reasonfor_NonCompliance_SelectBox_name, "name",
                        "visibletext", ReasonforNC)
                    time.sleep(2)
                    print(
                        "Where:" + PCNTYPE +
                        "and Effective and Received date < 180 then PCN Compliance is Autopopulates to :"
                        " " + strPCNComplience)
                    objCommon.capture_screenshot(
                        "PCN Compliance as: Non-Compliant ")
                else:
                    print("PCNComplience dropdown displaying as :"
                          " " + strPCNComplience + "insted of: Non-Compliant ")
                    assert strPCNComplience == "Non-Compliant"
            elif intSBDiff >= 180:
                if strPCNComplience == "Compliant":
                    print(
                        "Where:" + PCNTYPE +
                        "and Effective and Received date >=180 then PCN Compliance is Autopopulates to :"
                        " " + strPCNComplience)
                    objCommon.capture_screenshot(
                        "PCN Compliance as: Compliant ")
                else:
                    print("PCNComplience dropdown displaying as :"
                          " " + strPCNComplience + "insted of : Compliant")
                    assert strPCNComplience == "Compliant"
            elif intSBDiff < 180:
                if strPCNComplience == "Non-Compliant":
                    time.sleep(2)
                    objActions.selectDropdown(
                        PCN.Reasonfor_NonCompliance_SelectBox_name, "name",
                        "visibletext", ReasonforNC)
                    time.sleep(2)
                    print(
                        "Where:" + PCNTYPE +
                        "and Effective and Received date < 180 then PCN Compliance is Autopopulates to :"
                        " " + strPCNComplience)
                    objCommon.capture_screenshot(
                        "PCN Compliance as: Non-Compliant ")
                else:
                    print("PCNComplience dropdown displaying as :"
                          " " + strPCNComplience + "insted of: Non-Compliant ")
                    assert strPCNComplience == "Non-Compliant"
        else:
            print(
                "Failed: PCN Compliance not displaying Expected values  and  conditions are not satisfied"
            )
            objCommon.capture_screenshot("No Such element found")
Exemple #11
0
class createJPCN_Page():
    global objCommon, objActions, objConfig,objHome,objFilter,objSearch
    objCommon = CommonFunctions()
    objActions = PerformActions()
    objConfig=MyConfigFiles()
    objFilter=Filter()
    objHome=Home()


    def PCNIssue_DateSelection(self):
        time.sleep(2)
        objActions.clickElement(PCN.PCNIssue_Date_WebEdit_xpath, "xpath")
        intDay = objCommon.GetCurrentDay()
        strConcDate = "day-" + str(intDay)
        objActions.clickElement("//div[@aria-label='" + strConcDate + "']", "xpath")


    def PCNReceived_DateSelection(self):
        time.sleep(2)
        objActions.clickElement(PCN.PCNReceived_Date_WebEdit_xapth, "xpath")
        time.sleep(3)
        today = datetime.datetime.now(timezone('US/Pacific'))
        strReceivedDate = today.strftime("%d-%b-%Y")
        objActions.enterText(PCN.PCNReceived_Date_WebEdit_xapth, "xpath", strReceivedDate)
        date1 = datetime.datetime.strptime(strReceivedDate, "%d-%b-%Y")
        return date1

    def PCNEffective_DateSelection(self,PCN_EffDays):
        time.sleep(2)
        objActions.clickElement(PCN.PCNEffective_date_WebEdit_xpath, "xpath")
        time.sleep(3)
        UScurrent_date = datetime.datetime.now(timezone('US/Pacific'))
        UScurrent_date += datetime.timedelta(days=int(PCN_EffDays))
        strEffDate = UScurrent_date.strftime("%d-%b-%Y")
        objActions.enterText(PCN.PCNEffective_date_WebEdit_xpath, "xpath", strEffDate)
        date2 = datetime.datetime.strptime(strEffDate, "%d-%b-%Y")
        return date2


    def PCNLastTImeBuy_DateSelection(self,LT_BuyDays):
        time.sleep(2)
        objActions.clickElement(PCN.PCNLastTime_BuyDate_WebEdit_xpath, "xpath")
        time.sleep(3)
        UScurrent_date = datetime.datetime.now(timezone('US/Pacific'))
        UScurrent_date += datetime.timedelta(days=int(LT_BuyDays))
        strLasttimeBuyDate = UScurrent_date.strftime("%d-%b-%Y")
        objActions.enterText(PCN.PCNLastTime_BuyDate_WebEdit_xpath, "xpath", strLasttimeBuyDate)
        LBdate = datetime.datetime.strptime(strLasttimeBuyDate, "%d-%b-%Y")
        return LBdate

    def PCNLastTImeShip_DateSelection(self,LT_ShipDays):
        time.sleep(2)
        objActions.clickElement(PCN.PCNLastTime_ShipDate_WebEdit_xpath, "xpath")
        time.sleep(2)
        UScurrent_date = datetime.datetime.now(timezone('US/Pacific'))
        UScurrent_date += datetime.timedelta(days=int(LT_ShipDays))
        strLasttimeship = UScurrent_date.strftime("%d-%b-%Y")
        objActions.enterText(PCN.PCNLastTime_ShipDate_WebEdit_xpath, "xpath", strLasttimeship)
        LShipdate = datetime.datetime.strptime(strLasttimeship, "%d-%b-%Y")
        return LShipdate

    def CreateJPCN(self,SupplierName,SupplierPCN):
        objActions.clickElement(PCN.CreateJPCN_link_xpath, "xpath")
        print("Initiated Create JPCN Page and to fill Supplier info section")
        objActions.enterText(PCN.Suppliername_WebEdit_name, "name", SupplierName)
        time.sleep(2)
        objActions.clickElement("//div[text()='" + SupplierName + "']", "xpath")
        time.sleep(1)
        objActions.enterText(PCN.SupplierPCN_WebEdit_name, "name", SupplierPCN)
        time.sleep(2)
        strSC=objActions.getAttributeValue(PCN.SupplierContact_WebEdit_name, "name", "value")
        strSCE=objActions.getAttributeValue(PCN.SupplierContactEmail_WebEdit_name, "name", "value")
        strSP=objActions.getAttributeValue(PCN.SupplierPhone_WebEdit_name, "name", "value")
        strEC=objActions.getAttributeValue(PCN.SupplierEscalation_WebEdit_name, "name", "value")
        strECE=objActions.getAttributeValue(PCN.SupplierEscalationEmail_WebEdit_name, "name", "value")
        time.sleep(2)
        Supplier_allData=[SupplierName: '',SupplierPCN,strSC,strSCE,strSP,strEC,strECE]
        html = MyConfigFiles.driver.find_element_by_tag_name('html')
        html.send_keys(Keys.DOWN)
        # objActions.Page_Scroll_Actions("pcnReceivedDt", "name")
        print("sucessfully Filled the Supplier info section ")
        time.sleep(3)
        return Supplier_allData


    def PCN_DateSelections(self,PCN_EffDays, SelectPCNType, LT_BuyDays, LT_ShipDays):
        datelist = {}
        global intEFRCDiff,intBRDiff,intSBDiff
        print("Initiated to fill the  PCN/PDN INFO section")
        ReceivedDate=self.PCNReceived_DateSelection()
        time.sleep(2)
        EffectiveDate=self.PCNEffective_DateSelection(PCN_EffDays)
        time.sleep(2)
        self.PCNIssue_DateSelection()
        time.sleep(2)
        intEFRCDiff = int((EffectiveDate - ReceivedDate).days)
        print(intEFRCDiff)
        datelist['intEFRCDiff']=intEFRCDiff
        time.sleep(2)
        AllDate_ERdata = [ReceivedDate, EffectiveDate]
        if SelectPCNType == "EOL":
            objActions.selectDropdown(PCN.PCNType_Selectbox_name, "name", "visibletext", SelectPCNType)
            time.sleep(2)
            LTBuyDate = self.PCNLastTImeBuy_DateSelection(LT_BuyDays)
            time.sleep(2)
            LTShipDate = self.PCNLastTImeShip_DateSelection(LT_ShipDays)
            time.sleep(3)
            intBRDiff = int((LTBuyDate - ReceivedDate).days)
            time.sleep(2)
            print(intBRDiff)
            intSBDiff = int((LTShipDate - LTBuyDate).days)
            print(intSBDiff)
            datelist['intBRDiff']= intBRDiff
            datelist['intSBDiff']= intSBDiff
            time.sleep(5)
            html = MyConfigFiles.driver.find_element_by_tag_name('html')
            html.send_keys(Keys.TAB)
            time.sleep(7)
            AllDate_BSdata = [LTBuyDate, LTShipDate]
            return AllDate_BSdata
        else:
            objActions.selectDropdown(PCN.PCNType_Selectbox_name, "name", "visibletext", SelectPCNType)
        return datelist,SelectPCNType,AllDate_ERdata



    def PDNinfo_form(self,PCNSource,DescriptionChange,Natureofchange,Typeofchange,PendingConcernsComments):
        time.sleep(3)
        strPCNSource=objActions.selectDropdown(PCN.PCNSource_Selectbox_name, "name", "visibletext", PCNSource)
        time.sleep(3)
        strDC=objActions.enterText(PCN.Descriptionchange_WebEdit_name, "name" , DescriptionChange)
        time.sleep(3)
        strNC=objActions.selectDropdown(PCN.NatureofChange_Selectbox_name, "name", "visibletext", Natureofchange)
        time.sleep(3)
        strTC=objActions.selectDropdown(PCN.Typeofchange_Selectbox_xpath, "xpath", "visibletext", Typeofchange)
        time.sleep(3)
        objActions.clickElement(PCN.Add_Button_xpath, "xpath")
        time.sleep(3)
        print("sucessfully Filled the PCN/PDN INFO section")
        time.sleep(3)
        strPCC=objActions.enterText(PCN.OpenConcerns_Comments_WebEdit_name, "name", PendingConcernsComments)
        time.sleep(2)
        PCNPDN_allData=[strPCNSource,strDC,strNC,strTC,strPCC]
        objActions.clickElement(PCN.submit_button_xpath, "xpath")
        strJPCNID = objActions.getText(PCN.Jnpr_PCNID_xpath, "xpath")
        print("PCN/PDN & Supplier details are saved and PCN ID Created Successfully:" + strJPCNID)
        objCommon.capture_screenshot('Enter JPN-MPN details page.')
        return strJPCNID


    def Validate_CCE_PrePoulated_Values(self):
        objActions.getText(PCN.Verify_Context_CE_sections_xpath, "xpath")
        assert (objActions.AssertObjectExists(PCN.Verify_Context_CE_sections_xpath, "xpath"))
        time.sleep(1)
        strCCER_Act = objActions.ValidationOnSelectedtext(PCN.Validate_ContextCeRecommend_Value_name, "name")
        strCCER_Exp="No Action Needed"
        if strCCER_Act==strCCER_Act:
            print("Passed- Context CE Recommend Value is  " + strCCER_Act)
        else:
            print("Failed- Context CE Recommend Value is " + strCCER_Act +  "instead of"  + strCCER_Exp)
        assert strCCER_Act == strCCER_Act
        time.sleep(2)
        strPCNStatus_Act = objActions.ValidationOnSelectedtext(PCN.Validate_PCNStatus_Value_name, "name")
        strPCNStatus_Exp = "Closed - No Usage at Juniper"
        if strPCNStatus_Act==strPCNStatus_Act:
            print("Passed- PCN Status is  " + strPCNStatus_Act)
        else:
            print("Failed- PCN Status is " + strPCNStatus_Act +  "instead of"  + strPCNStatus_Exp)
        assert strPCNStatus_Act == strPCNStatus_Act
        time.sleep(2)
        strPCNStatusComm_Act = objActions.getText(PCN.Validate_PCNStatusComment_Value_name, "name")
        strPCNStatusComm_Exp = "MPNs included in this PCN are not in use at Juniper. Thus JPCN created at Juniper for records and closed as No Action Needed."
        if strPCNStatusComm_Act==strPCNStatusComm_Act:
            print("Passed- PCN Status comments is  " + strPCNStatusComm_Act)
        else:
            print("Failed- PCN Status comments is "  + strPCNStatusComm_Act +  "instead of" + strPCNStatusComm_Exp)
        assert strPCNStatusComm_Act == strPCNStatusComm_Act
        time.sleep(2)
        strResponsibleCE_Act = objActions.ValidationOnSelectedtext(PCN.Validate_ResponsibleCE_Value_name, "name")
        strResponsibleCEUN = objActions.getText(PCN.Login_Username_WebElement_xpath, "xpath")
        s= strResponsibleCEUN.split(",")[1]
        strResponsibleCE_Exp=s.strip()
        print(strResponsibleCE_Exp)
        if strResponsibleCE_Act==strResponsibleCE_Exp:
            print("Passed- Respobible CE is  " +  strResponsibleCE_Act)
        else:
            print("Failed- Respobible CE is " +  strResponsibleCE_Act +  "instead of" +  strResponsibleCE_Exp)
        assert strResponsibleCE_Act == strResponsibleCE_Exp
        time.sleep(2)
        strPCNCompliance_Act = objActions.ValidationOnSelectedtext(PCN.Validate_PCNCompliance_Value_name, "name")
        strPCNCompliance_Exp = "Not-Applicable"
        if strPCNCompliance_Act == strPCNCompliance_Exp:
            print("Passed- PCN Compliance is  " + strPCNCompliance_Act)
        else:
            print("Failed- PCN Compliance is " + strPCNCompliance_Act + "instead of" + strPCNCompliance_Exp)
        assert strPCNCompliance_Act == strPCNCompliance_Exp
        time.sleep(3)

    def ClosethisPCN(self,PCNStatus_Closed):
         objActions.selectDropdown(PCN.Validate_PCNStatus_Value_name, "name", "visibletext", PCNStatus_Closed)
         time.sleep(2)
         objActions.clickElement(PCN.Close_ThisPCN_Button_xpath, "xpath")
         print("PCN Closed sucessfully")

    def Validate_InvalidPCN_Status(self,PCNStatus):
        objActions.selectDropdown(PCN.Validate_PCNStatus_Value_name, "name", "visibletext", PCNStatus)
        time.sleep(2)
        objActions.clickElement(PCN.Close_ThisPCN_Button_xpath, "xpath")
        time.sleep(2)
        strIPCNS_Act=objActions.getText(PCN.Validation_msg_WebElement_xpath, "xpath")
        time.sleep(2)
        strIPCNS_Exp="Invalid PCN Status"
        if strIPCNS_Act==strIPCNS_Exp:
            print("Passed - Validation Message is dispalying as::"  " "+strIPCNS_Act)
        else:
            print("Failed -NO validation message is displayed")
        assert strIPCNS_Act == strIPCNS_Exp


    def Uploadvalidation(self):
        strAcknowMsg=objActions.getText(PCN.Acknowledgement_Notification_msg_xapth, "xpath")
        print("Acknowledgement Notification Message is :" +strAcknowMsg)
        assert (objActions.AssertObjectExists(PCN.Acknowledgement_Notification_msg_xapth, "xpath"))
        time.sleep(1)
        objActions.clickElement(PCN.Acknowledgement_Notification_button_xpath, "xpath")
        print("Acknowledgement Notification button: OK button clicked sucessfully")

    def JPN_MPN_Info(self,strFilePath):
        objCommon.AttachFile(strFilePath,PCN.Choosefile_button_name, "name")
        objActions.clickElement(PCN.Upload_button_xpath,"xpath")

    def EOL_Upload_Validations(self,strResponsibleCoreCE):
    #     time.sleep(2)
    #     # objCommon.AttachFile(strFilePath,PCN.EOL_Investigation_button_xpath,"xpath")
    #     # time.sleep(10)
    #     # html = MyConfigFiles.driver.find_element_by_tag_name('html')
    #     # html.send_keys(Keys.PAGE_UP)
    #     # time.sleep(5)
    #     # objActions.clickElement(PCN.EOL_Investigation_Upload_Lnk_xpath, "xpath")
    #     # time.sleep(20)
        strUploadtxt=objActions.getText(PCN.EOL_UPload_WebElement_xpath, "xpath")
        print("Expected linke is dislaying is:" " "+strUploadtxt)
        objActions.AssertObjectExists(PCN.EOL_UPload_WebElement_xpath, "xpath")
        time.sleep(2)
        strDownloadtxt = objActions.getText(PCN.EOL_Download_WebElement_xpath, "xpath")
        print("Expected linke is dislaying is:" " " + strDownloadtxt)
        objActions.AssertObjectExists(PCN.EOL_Download_WebElement_xpath, "xpath")
        time.sleep(2)
        strDeletetxt = objActions.getText(PCN.EOL_Delete_WebElement_xpath, "xpath")
        print("Expected linke is dislaying is:" " " + strDeletetxt)
        objActions.AssertObjectExists(PCN.EOL_Delete_WebElement_xpath, "xpath")
        objCommon.capture_screenshot("EOL file Uploaded sucessfully with all the buttons.")
        time.sleep(2)
        element = MyConfigFiles.driver.find_element_by_xpath("//button[contains(text(),'Save & Continue')]")
        print("Save and Continue button  is  Enabled:",element.is_enabled())
        time.sleep(2)
        objActions.selectDropdown(PCN.JPN_MPN_Responsible_CoreCE_Selectbox_name, "name", "visibletext", strResponsibleCoreCE)
        time.sleep(2)
        print("Save and Continue button is Enabled:" "" , element.is_enabled())
        time.sleep(2)
        objCommon.capture_screenshot("Save and Continue is enabled")


    def JPN_MPN_Info_ValidationCheck(self):
        strNRF_Act=objActions.getText(PCN.Jnpr_UA_Validation_msg_xpath, "xpath")
        strNRF_Exp= "No Record Found!"
        if strNRF_Act==strNRF_Exp:
            print("Passed- MPNs such should not have any impact on agile it is display:" +strNRF_Act)
        else:
            print("Failed- No Error messge is displayed as :" +strNRF_Act)
        assert strNRF_Act==strNRF_Exp

    def Verify_BackButton_Navigation(self):
        time.sleep(2)
        objActions.clickElement(PCN.Back_JPCNPage_button_xpath, "xpath")
        objCommon.capture_screenshot(" Enter PCN details page displyed sucessfully")


    def Edit_EnterPCNDetails_Page(self,SupplierPCN):
        SPCNUpdate="edit"
        time.sleep(2)
        objActions.enterText(PCN.SupplierPCN_WebEdit_name, "name", SPCNUpdate)
        time.sleep(2)
        objActions.clickElement(PCN.submit_button_xpath, "xpath")
        time.sleep(2)
        objActions.clickElement(PCN.Back_JPCNPage_button_xpath, "xpath")
        time.sleep(1)
        strupdated=objActions.getAttributeValue(PCN.SupplierPCN_WebEdit_name, "name", "value")
        print("the values is:"+strupdated)
        if SupplierPCN != strupdated:
            print("Successfully Edited Supplier PCN value:-"," "+strupdated)
        else:
            print("Not Edited the Supplier PCN Value:", " "+strupdated)
        assert SupplierPCN != strupdated
        time.sleep(2)
        objActions.clickElement(PCN.submit_button_xpath, "xpath")
        time.sleep(2)

    def AddNewAttachement_JPNMPN(self,strCategory,strFilePath,Comments):
        objActions.clickElement(PCN.JPN_MPN_AddNew_Attachment_button_xpath, "xpath")
        time.sleep(2)
        objActions.selectDropdown(PCN.AddNewAttachement_Category_Selectbox_xpath, "xpath", "visibletext", strCategory)
        time.sleep(2)
        objCommon.AttachFile(strFilePath, PCN.AddNewAttachement_Choose_file_xapth, "xpath")
        time.sleep(5)
        objActions.enterText(PCN.AddNewAttachement_Comments_xpath, "xpath", Comments)
        objActions.clickElement(PCN.AddNewAttachement_SubmitBtn_xpath, "xpath")
        time.sleep(3)

    def DeleteAttachement(self):
        global flag
        time.sleep(2)
        objTable = MyConfigFiles.driver.find_elements_by_xpath("//table[@id='attachment']/tbody/tr")
        intRowCount = len(objTable)
        flag = False
        for i in range(2, intRowCount + 1):
            stri = str(i)
            objActions.getText("//table[@id='attachment']/tbody/tr[" + stri + "]/td[1]", "xpath")
            time.sleep(2)
            objActions.clickElement("//table[@id='attachment']/tbody/tr[" + stri + "]/td[1]", "xpath")
            time.sleep(2)
            alert_obj = MyConfigFiles.driver.switch_to.alert
            alert_obj.accept()
            time.sleep(2)
            objTable = MyConfigFiles.driver.find_elements_by_xpath("//table[@id='attachment']/tbody/tr")
            intRowCountafterdel = len(objTable)
            if intRowCount != intRowCountafterdel:
                print("Present Row count is :"+str(intRowCountafterdel))
                objCommon.capture_screenshot("Selected Row deleted sucessfully")
                break
            if flag == True:
                 break
            else:
                sys.exit("FAILED:: Row Not delected: " + stri)


    # def EOL_InvistigationFileUpload_fromJPNTable(self,strFilePath):
    #     time.sleep(2)
    #     objTablerow = MyConfigFiles.driver.find_elements_by_xpath("//table[@id='upload-jpn']/tbody/tr")
    #     intRowCount = len(objTablerow)
    #     # print("Rows Count in page  is: " + str(intRowCount - 1))
    #     flag = False
    #     for i in range(1, intRowCount + 1):
    #         stri = str(i)
    #         # print(stri)
    #         objTablecol = MyConfigFiles.driver.find_elements_by_xpath("//table[@id='upload-jpn']/tbody/tr/th")
    #         intColCount = len(objTablecol)
    #         for j in range(i, intColCount + 1):
    #              strj = str(j)
    #         print("Column count is :" + str(intColCount - 1))
    #         strColumheaders = objActions.getText("//table[@id='upload-jpn']//tbody//tr[" + stri + "]//th[" + strj + "]", "xpath")
    #         time.sleep(2)
    #         # print(strColumheaders)
    #         time.sleep(2)
    #         if "EOL" in strColumheaders:
    #             for k in range(i + 1, intRowCount - 1):
    #                 strk = str(k)
    #                 # print(strk)
    #                 strChoosefile = objActions.getText("//table[@id='upload-jpn']/tbody//tr[" + strk + "]//td[" + strj + "]", "xpath")
    #                 print(strChoosefile)
    #                 if strChoosefile == '':
    #                     time.sleep(3)
    #                     objActions.getText("//table[@id='upload-jpn']/tbody//tr[" + strk + "]//td[" + strj + "]//span[1]//input[1]", "xpath")
    #                     time.sleep(3)
    #                     objCommon.AttachFile(strFilePath, "//table[@id='upload-jpn']/tbody//tr[" + strk + "]//td[" + strj + "]//span[1]//input[1]","xpath")
    #                     time.sleep(1)
    #                     objActions.Page_Scroll_Actions("JpnInput", "id")
    #                     time.sleep(3)
    #                     objActions.clickElement("//table[@id='upload-jpn']/tbody//tr[" + strk + "]//td[" + strj + "]//span[1]//p[1]//a[1]", "xpath")
    #                     time.sleep(5)
    #                     flag = True
    #                     print("EOL Form is uploaded sucessfully: ")
    #                     # break
    #         break




    def PreviewScreen_Validations(self,PendingConcernsComments):
        objActions.clickElement(PCN.JPN_MPN_Button_xpath, "xpath")
        time.sleep(2)
        objActions.clickElement(PCN.MultipleCoreCE_POpUp_Button_xpath, "xpath")
        time.sleep(2)
        objCommon.capture_screenshot("Preview screen popup text ")
        time.sleep(2)
        PlaceHolder_Acttext=objActions.getText(PCN.Placeholder_text_WebElement_name, "name")
        # print(PlaceHolder_Acttext)
        if PlaceHolder_Acttext == PendingConcernsComments:
            print("Preview screen will appear with the Pending Info Comments given in the first page as :"+PlaceHolder_Acttext)
            objCommon.capture_screenshot("Preview Screen comments")
            objActions.clickElement(PCN.PreviewScreen_button_xpath, "xpath")
        else:
            print("Failed: Preview screen not displaying comments")
            time.sleep(2)
        assert PlaceHolder_Acttext == PendingConcernsComments


    def MultipleCoreCE_Selection(self,strJPNID):
        objActions.clickElement(PCN.JPN_MPN_Button_xpath, "xpath")
        time.sleep(2)
        objCommon.capture_screenshot("JPCN is having multiple Core CE.")
        objActions.clickElement(PCN.MultipleCoreCE_POpUp_NoButton_xpath, "xpath")
        objCommon.capture_screenshot("How would you like to solve the multiple Core CE issue?.")
        time.sleep(2)
        objActions.clickElement(PCN.MultipleCoreCE_Duplicate_Button_xpath, "xpath")
        objCommon.capture_screenshot("Preview screen popup text ")
        time.sleep(2)
        html = MyConfigFiles.driver.find_element_by_tag_name('html')
        html.send_keys(Keys.PAGE_UP)
        strJPCNDuplicate_Msg= objActions.getText(PCN.MultipleCoreCE_Duplication_Msg_xpath, "xpath")
        objCommon.capture_screenshot("JPCN Duplication is Completed!")
        assert(strJPCNDuplicate_Msg)
        time.sleep(2)
        objActions.clickElement(PCN.Newly_duplicatedJPCN_Link_xpath, "xpath")
        time.sleep(2)
        JPCN_Duplicate=objActions.getText(PCN.Jnpr_PCNID_xpath, "xpath")
        if JPCN_Duplicate != strJPNID:
            print("New Duplicate JPCN id created Sucessfully")

        # PlaceHolder_Acttext=objActions.getText(PCN.Placeholder_text_WebElement_name, "name")
        # # print(PlaceHolder_Acttext)
        # if PlaceHolder_Acttext == PendingConcernsComments:
        #     print("Preview screen will appear with the Pending Info Comments given in the first page as :"+PlaceHolder_Acttext)
        #     objCommon.capture_screenshot("Preview Screen comments")
        #     objActions.clickElement(PCN.PreviewScreen_button_xpath, "xpath")
        # else:
        #     print("Failed: Preview screen not displaying comments")
        #     time.sleep(2)
        # assert PlaceHolder_Acttext == PendingConcernsComments


    # Expand Supplier info sections and Edit the few details.

    def Verify_SupplierInfo_Edit_ProductData_Section(self):
        time.sleep(3)
        objActions.Page_Scroll_Actions("//p[contains(text(),'Supplier Info')]", "xpath")
        time.sleep(3)
        objActions.clickElement(PCN.Expand_SupplierInfo_Button_xpath, "xpath")
        time.sleep(2)
        strGetItems=MyConfigFiles.driver.find_elements_by_xpath("//div[@class='supplier-info-section padding-around show-it']//button[contains(text(),'Edit')]")
        print(len(strGetItems))
        intcount=len(strGetItems)
        if intcount > 0:
            objActions.clickElement(PCN.Expand_SupplierInfo_Edit_Button_xpath, "xpath")
            time.sleep(2)
            objActions.enterText(PCN.SampleOwner_Contact_WebEdit_name, "name", "automation")
            time.sleep(2)
            objActions.clickElement(PCN.Expand_SupplierInfo_Save_Button_xpath, "xpath")
            objCommon.capture_screenshot("Supplier info sections edited sucessfully with sample Owner Conatct:")
            time.sleep(2)
            objActions.clickElement(PCN.Expand_SupplierInfo_Button_xpath, "xpath")
        else:
            objActions.clickElement(PCN.Expand_SupplierInfo_Button_xpath, "xpath")
            print("Edit button not  displyed in the Supplier info secession and all the fields are read only ")




    # Compare SupplierInfo data from first page and verify productData page

    def Compare_Supplierinfodata_in_verifyproductsection(self,SupplierName,strupdated,strSC,strSCE,strSP,strEC,strECE):
        time.sleep(3)
        objActions.Page_Scroll_Actions("//p[contains(text(),'Supplier Info')]", "xpath")
        time.sleep(3)
        objActions.clickElement(PCN.Expand_SupplierInfo_Button_xpath, "xpath")
        time.sleep(2)
        strSN=objActions.getAttributeValue(PCN.Suppliername_WebEdit_name, "name", "value")
        if SupplierName == strSN:
           print("Passed: SupplierName from the fistpage and VerifyProduct page are same :"  " " +strSN)
        else:
            print("Failed: SupplierName displaying as:" +strSN+ "insted of:"  +SupplierName)
        assert SupplierName == strSN
        time.sleep(2)
        # strPCN = objActions.getAttributeValue(PCN.SupplierPCN_WebEdit_name, "name", "value")
        # if strupdated == strPCN:
        #     print("Passed: SupplierPCN from the fistpage and VerifyProduct page are same :"  " " +strPCN)
        # else:
        #     print("Failed: SupplierPCN displaying as:" +strPCN + "insted of:" +strupdated)
        # assert strupdated == strPCN
        time.sleep(2)
        strSC_VPD=objActions.getAttributeValue(PCN.SupplierContact_WebEdit_name, "name", "value")
        if strSC == strSC_VPD:
            print("Passed: SupplierContact from the fistpage and VerifyProduct page are same :"  " " +strSC_VPD)
        else:
            print("Failed: SupplierContact displaying as:" +strSC_VPD + "insted of:" +strSC)
        assert strSC== strSC_VPD
        time.sleep(2)
        strSCE_VPD = objActions.getAttributeValue(PCN.SupplierContactEmail_WebEdit_name, "name", "value")
        if strSCE == strSCE_VPD:
            if strSC == strSC_VPD:
                print("Passed: SupplierContactEmail from the fistpage and VerifyProduct page are same :"  " " +strSCE_VPD)
        else:
                print("Failed: SupplierContactEmail displaying as:" +strSCE_VPD+ "insted of:" +strSCE)
        assert strSCE == strSCE_VPD
        time.sleep(2)
        strSP_VPD = objActions.getAttributeValue(PCN.SupplierPhone_WebEdit_name, "name", "value")
        if  strSP ==  strSP_VPD:
            print("Passed: SupplierPhone from the fistpage and VerifyProduct page are same :"  " " +strSP_VPD)
        else:
            print("Failed: Supplier phone displaying as:" +strSP_VPD+ "insted of:" +strSP)
        assert strSP == strSP_VPD
        time.sleep(2)
        strEC_VPD = objActions.getAttributeValue(PCN.SupplierEscalation_WebEdit_name, "name", "value")
        if strEC == strEC_VPD:
            print("Passed: SupplierEC from the fistpage and VerifyProduct page are same :"  " "  +strEC_VPD)
        else:
            print("Failed: SupplierEC displaying as:" +strEC_VPD+ "insted of:" +strEC)
        assert strEC == strEC_VPD
        time.sleep(2)
        strECE_VPD = objActions.getAttributeValue(PCN.SupplierEscalationEmail_WebEdit_name, "name", "value")
        if strECE == strECE_VPD:
            print("Passed: SupplierECEmail from the fistpage and VerifyProduct page are same :"  " "  +strECE_VPD)
        else:
            print("Failed: SupplierECEmail displaying as" +strECE_VPD+ "insted of:" +strECE)
        assert strECE == strECE_VPD
        time.sleep(2)



    def Verify__PCN_PDNinfo_Edit_ProductData_Section(self,DescriptionChange):
        time.sleep(3)
        objActions.clickElement(PCN.Expand_PCN_PDNinfo_Button_xpath, "xpath")
        time.sleep(2)
        strGetItems = MyConfigFiles.driver.find_elements_by_xpath("//div[@class='PCN-PDN-info-section padding-around show-it']//button[contains(text(),'Edit')]")
        print(len(strGetItems))
        intcount = len(strGetItems)
        if intcount > 0:
            objActions.clickElement(PCN.Expand_PCN_PDNInfo_Edit_Button_xpath, "xpath")
            AppendValue= "Edited"
            objActions.enterText(PCN.Descriptionchange_WebEdit_name, "name" , AppendValue)
            time.sleep(2)
            html = MyConfigFiles.driver.find_element_by_tag_name('html')
            html.send_keys(Keys.PAGE_UP)
            time.sleep(3)
            objActions.clickElement(PCN.Expand_PCN_PDNInfo_Save_Button_xpath, "xpath")
            time.sleep(2)
            Act_DescChange = objActions.getAttributeValue(PCN.Descriptionchange_WebEdit_name, "name", "value")
            if DescriptionChange != Act_DescChange:
                print("Successfully Edited Description Change  value:", " " + Act_DescChange)
            else:
                print("Failed: Description values displaying:" +DescriptionChange+ "Insted of ", " " + Act_DescChange)
            assert DescriptionChange != Act_DescChange
            time.sleep(2)
            objActions.clickElement(PCN.Expand_PCN_PDNinfo_Button_xpath, "xpath")
        else:
            objActions.clickElement(PCN.Expand_PCN_PDNinfo_Button_xpath, "xpath")
            print("Edit button not displyed in the PDN_PCN info secession and all the fields are read only")



    def WhereUserAnalysis(self,PCNTYPE,strCategory,strFilePath,Comments):
        if PCNTYPE == "EOL":
            objActions.clickElement(PCN.submit_button_xpath, "xpath")
            time.sleep(2)
            UserAnalysis_Required = objActions.getText(PCN.Validation_Msg_UserAanlysis_xpath, "xpath")
            print("Where Use Analysis is Mandatory to click and otherwise validation message is:" +UserAnalysis_Required)
            time.sleep(2)
            objActions.clickElement(PCN.Where_UserAnalysis_button_xapth, "xpath")
            objCommon.capture_screenshot("Where User analysis clicked sucessfully")
            objActions.clickElement(PCN.Completed_Page_OK_button_xpath, "xpath")
            time.sleep(2)
            objActions.clickElement(PCN.Back_JPCNPage_button_xpath, "xpath")
            objCommon.capture_screenshot("Page navigates to Enter JPN-MPN Deatils page")
            time.sleep(2)
            self.AddNewAttachement_JPNMPN(strCategory,strFilePath,Comments)
            time.sleep(3)
            objActions.clickElement(PCN.JPN_MPN_Button_xpath, "xpath")
            objCommon.capture_screenshot("Page navigates to Verify produce  page")
            objActions.clickElement(PCN.submit_button_xpath, "xpath")
            time.sleep(2)
            PCN_CompletedMsg = objActions.getText(PCN.Validation_Msg_PCNCreations_xpath, "xpath")
            print(PCN_CompletedMsg)
            objCommon.capture_screenshot("New PCN Create sucessfully")
            objActions.clickElement(PCN.Completed_Page_OK_button_xpath, "xpath")
            objCommon.capture_screenshot("Sucessfully navigate to the JPCN Status Overview page")
        else:
            objActions.clickElement(PCN.submit_button_xpath, "xpath")
            time.sleep(2)
            PCN_CompletedMsg = objActions.getText(PCN.Validation_Msg_PCNCreations_xpath, "xpath")
            print(PCN_CompletedMsg)
            objCommon.capture_screenshot("New PCN Create sucessfully")
            objActions.clickElement(PCN.Completed_Page_OK_button_xpath, "xpath")
            time.sleep(2)
            objCommon.capture_screenshot("Sucessfully navigate to the JPCN Status Overview page")


# Count the highest occurrence of core CE names

    def GetCoreCENames(self):
        objTablerow = MyConfigFiles.driver.find_elements_by_xpath("//table[@id='upload-jpn']/tbody/tr")
        intRowCount = len(objTablerow)
        print(intRowCount)
        strCoreCEList1 = []
        for strCoreCEList in MyConfigFiles.driver.find_elements_by_xpath("//table[@id='upload-jpn']/tbody/tr/td[14]"):
            strCoreCEList1.append(strCoreCEList.text)
            print(strCoreCEList.text)
            print(strCoreCEList1)
            CoreCESet = set(strCoreCEList1)
            CoreCEList = list(CoreCESet)
            print(CoreCEList)
            CoreCENames = len(CoreCEList)
            print(CoreCENames)
            CoreCount = 0
            for x in CoreCEList:
                CoreCount1 = CoreCount
                CoreCount=0
                # CoreCount = strCoreCEList1.count(x)
                # print(CoreCount)
                if CoreCount > CoreCount1:
                    CoreCount1 = CoreCount
                    print(x)

    # def Page_Scroll_Actions(self,element):
    #     actions = ActionChains(MyConfigFiles.driver)
    #     element = MyConfigFiles.driver.find_element_by_name('name')
    #     actions.move_to_element(element)
    #     actions.perform()

    def DeleteAttachement_PRrows(self):
        global flag
        time.sleep(4)
        objTable = MyConfigFiles.driver.find_elements_by_xpath("//div[@id='Core-Ce-Details']//table[@id='pr']/tbody/tr")
        intRowCount = len(objTable)
        flag = False
        for i in range(2, intRowCount + 1):
            stri = str(i)
            objActions.getText("//div[@id='Core-Ce-Details']//table[@id='pr']/tbody/tr[" + stri + "]/td[1]", "xpath")
            time.sleep(2)
            objActions.clickElement("//div[@id='Core-Ce-Details']//table[@id='pr']/tbody/tr[" + stri + "]/td[1]", "xpath")
            time.sleep(2)
            alert_obj = MyConfigFiles.driver.switch_to.alert
            alert_obj.accept()
            time.sleep(2)
            objTable = MyConfigFiles.driver.find_elements_by_xpath("//div[@id='Core-Ce-Details']//table[@id='pr']/tbody/tr")
            intRowCountafterdel = len(objTable)
            if intRowCount != intRowCountafterdel:
                print("Present Row count is :"+str(intRowCountafterdel))
                objCommon.capture_screenshot("Selected Row deleted sucessfully")
                break
            if flag == True:
                 break
            else:
                sys.exit("FAILED:: Row Not delected: " + stri)



    def ClickOnJPN_MPN_Exapnd(self):
        time.sleep(4)
        objActions.clickElement(PCN.Expand_JPN_MPN_Button_xpath, "xpath")
        time.sleep(4)



#***********************************************************************************************************
    def EOL_InvistigationFileUpload_fromJPNTable1(self, strFilePath):
        global flag
        time.sleep(2)
        strPages = objActions.getText(PCN.ContextCE_TablePage_Count_xpath, "xpath")
        strPagesCount = strPages.split(" ")
        intPagesCount = int(strPagesCount[4])
        if intPagesCount <= 1:
            time.sleep(30)
        flag = False
        for pages in range(1, intPagesCount + 1):
            objTable = MyConfigFiles.driver.find_elements_by_xpath("//table[@id='upload-jpn']/tbody/tr")
            intRowCount = len(objTable)
            for i in range(2, intRowCount + 1):
                stri = str(i)
                objTablecol = MyConfigFiles.driver.find_elements_by_xpath("//table[@id='upload-jpn']/tbody/tr/th")
                intColCount = len(objTablecol)
                for j in range(i, intColCount + 1):
                    strj = str(j)
                    strchoosefile = objActions.getText("//table[@id='upload-jpn']/tbody/tr[" + stri + "]/td[" + strj + "]", "xpath")
                    if strchoosefile == "Upload":
                        time.sleep(2)
                        objActions.getText("//table[@id='upload-jpn']/tbody//tr[" + stri + "]//td[" + strj + "]//span[1]//input[1]", "xpath")
                        time.sleep(3)
                        objCommon.AttachFile(strFilePath, "//table[ @ id = 'upload-jpn']/ tbody// tr[" + stri + "]//td[" + strj + "]// span[1]// input[1]", "xpath")
                        time.sleep(1)
                        objActions.Page_Scroll_Actions("JpnInput", "id")
                        time.sleep(3)
                        objActions.clickElement("//table[@id='upload-jpn']/tbody//tr[" + stri + "]//td[" + strj + "]//span[1]//p[1]//a[1]", "xpath")
                        time.sleep(5)
                        flag = True
                        print("EOL file Upload sucessfully and file name is: "+strFilePath)
                        break
                        time.sleep(10)
                if flag == True:
                    break
        if flag == False:
                sys.exit("FAILED:: Could not find the Upload Choose file option: " + strFilePath)


    def get_all_data(self):
        # get number of rows
        noOfRows = len(MyConfigFiles.driver.find_elements_by_xpath("//table[@class='font-size-regular']/tbody/tr"))
        print(noOfRows)
        # get number of columns
        noOfColumns = len(MyConfigFiles.driver.find_elements_by_xpath("//table[@class='font-size-regular']/tbody/tr/td"))
        print(noOfColumns)
        allData = []
        print(allData)
        # iterate over the rows, to ignore the headers we have started the i with '1'
        for i in range(1, noOfRows):
            # reset the row data every time
            ro = []
            # iterate over columns
            for j in range(i, noOfColumns):
                # get text from the i th row and j th column
                ro.append(objActions.getText("//table[@class='font-size-regular']/tbody/tr[" + str(i) + "]/td[" + str(j) + "]", "xpath"))
                # ro.append(MyConfigFiles.driver.find_elements_by_xpath("//table[@class='font-size-regular']/tbody/tr[" + str(i) + "]/td[" + str(j) + "]")
            # add the row data to allData of the self.table
            allData.append(ro)
        return allData
Exemple #12
0
def movfiletodir(file_name):
    PerformActions._createdirectory(MyConfigFiles.ScreenShot_ReportFile_Path + 'Failed')
    shutil.move(MyConfigFiles.ScreenShot_ReportFile_Path + file_name, MyConfigFiles.ScreenShot_ReportFile_Path + 'Failed')
Exemple #13
0
class Search_Page():
    global objCommon, objActions, objConfig, objFilter, objHome, objCreateJPCN
    objCommon = CommonFunctions()
    objActions = PerformActions()
    objConfig = MyConfigFiles()
    objFilter = Filter()
    objHome = Home()
    objCreateJPCN = createJPCN_Page()

    def Search_For_ClosedPCN_And_ClickEditIcon(self):
        strPages = objActions.getText(PCN.Search_TablePage_Count_xpath,
                                      "xpath")
        strPagesCount = strPages.split(" ")
        PageCount = int(strPagesCount[4])
        # GetPagesLinks=MyConfigFiles.driver.find_elements_by_xpath("//div[@class='content']//li//a")
        # PageCount=len(GetPagesLinks)
        print(PageCount)
        objTablerow = MyConfigFiles.driver.find_elements_by_xpath(
            "//table[@id='created-jpcn']/tbody/tr")
        intRowCount = len(objTablerow)
        print("Rows Count in page  is: " + str(intRowCount - 1))
        flag = False
        for t in range(1, PageCount + 1):
            # t=t+1
            # strt = str(t+1)
            # if t==PageCount-1:
            # break
            for i in range(2, intRowCount + 1):
                stri = str(i)
                strJCPNStage = objActions.getText(
                    "//table[@id='created-jpcn']/tbody/tr[" + stri + "]/td[7]",
                    "xpath")
                if strJCPNStage == "Core CE Assessment":
                    EditIconExists = objActions.ObjectExists(
                        "//table[@id='created-jpcn']/tbody//tr[" + stri +
                        "]//td[2]//img[@class='editIcon iconLink']", "xpath")
                    # CoreCEAssessment_JPCNNumber = objActions.getText("//table[@id='created-jpcn']/tbody//tr[" + stri + "]//td[3]")
                    CoreCEAssessment_JPCNNumber = MyConfigFiles.driver.find_element_by_xpath(
                        "//table[@id='created-jpcn']/tbody//tr[" + stri +
                        "]//td[3]").text
                    objActions.clickElement(
                        "//table[@id='created-jpcn']/tbody//tr[" + stri +
                        "]//td[2]//img[@class='editIcon iconLink']", "xpath")
                    if EditIconExists == True:
                        flag = True
                        print("Able to edit Closed JPCN")
                        break
            if flag == True:
                break
            elif t == PageCount:
                break
            else:
                time.sleep(2)
                objActions.clickElement("//a[text()='" + str(t + 1) + "']",
                                        "xpath")
                time.sleep(2)
        if flag == False:
            sys.exit("FAILED:: Could not find the JPCNNumber ")
        else:
            print("Core CE Assessment JPCN is " + CoreCEAssessment_JPCNNumber +
                  "and successfully clicked edit icon")
        return CoreCEAssessment_JPCNNumber