def login(driver, reportfilepath, base_url, username, password, screenshotpath): # global driver global ReportRootPath # global strReportImageFolderPath driver.get(base_url) report.ReportHTMLLog("Pass", "Launch SXP URL", " SXP URL " + base_url + " Launched") control.wait(10) # Check Spinner : if not driver.find_element_by_xpath( "//div[@class='loading-spinner']").is_displayed(): driver.find_element_by_id("loginlink").click() if driver.find_element_by_id("loginlink").is_displayed(): driver.find_element_by_name("username").send_keys(username) driver.find_element_by_name("password").send_keys(password) driver.find_element_by_xpath( "//*[@id='gigya-login-form']/div/div/div/input[@type='submit' and @class='gigya-input-submit']" ).click() else: report.ReportHTMLLog( "Fail", "Page Load Time", " Home Page is not loaded in 15 Seconds.") report.CaptureScreenShot("Test Image", screenshotpath) else: report.ReportHTMLLog.ReportHTMLLog( "Fail", "Spinner Time", " Spinner is not loaded in 30 Seconds.")
def test_TC011_SXP_Result_Table_Differences(self): try: global driver, imagename, imagecount, tc_execflag, qc_tester, qc_tc_exec_path, qc_ts_name appname = config.appname strCurrTestName = self._testMethodName.replace('test_', '').strip() # Initialize Report : base_url = config.base_url.strip() # Driver SetUp : implicitly_wait = config.implicitly_wait mobile_emulation = 'No' mobile_device = 'iPad' # iPhone 6/7/8 Plus,iPhone X,iPad,iPad Pro driver = drivers.setup(config.drivertype, config.driverpath, mobile_emulation, mobile_device, implicitly_wait) # read execution flag from Database DBData = dbutility(config.DB_Prod_Server, config.DB_Name, config.DB_Port, config.DB_User, config.DB_Prod_Pwd) tc_execflag, qc_tester, qc_tc_exec_path, qc_ts_name = DBData.ReadTCExecDetailsFromDB( appname, strCurrTestName) blnCrossSearchResultsFlag = False # Execution Flag If condition if tc_execflag.lower().strip() == 'Yes'.lower().strip(): testcasedescription = strCurrTestName # Initialize Report reportfilepath, screenshotpath = report.InitializeReport( config.ReportRootPath, strCurrTestName, testcasedescription) # Read Test Data SXP_User = DBData.ReadParaValueFromDB(appname, strCurrTestName, "DT_SXP_USER") SXP_Password = DBData.ReadParaValueFromDB( appname, strCurrTestName, "DT_SXP_PASSWORD") strRootPart = DBData.ReadParaValueFromDB( appname, strCurrTestName, "DT_ROOT_PART") strSearchKeyWord = DBData.ReadParaValueFromDB( appname, strCurrTestName, "DT_ORDERABLE_PART") StrColList = DBData.ReadParaValueFromDB( appname, strCurrTestName, "DT_CROSS_TYPE_FIELD") strColumnValues = DBData.ReadParaValueFromDB( appname, strCurrTestName, "DT_CROSS_TYPE_FIELD_VALUE") strLsColumnList = [] strLsColumnList.extend(str(StrColList).split(";")) strLsColumnValue = [] strLsColumnValue.extend(str(strColumnValues).split(';')) # ****************************** START ****************************** #Login and Login Validation action.login(driver, reportfilepath, base_url, SXP_User, SXP_Password, screenshotpath) # Step 2 and 3 START : Enter "MAX232ACPE+" and Press "Enter" or Click Search icon #Set Search Text driver.find_element_by_id("cross-search-bar").send_keys( strRootPart) control.wait(1) report.CaptureScreenShot(f"Search KeyWord {strRootPart}", screenshotpath) #Click Search icon driver.find_element_by_id("cross-search-bar").submit() control.wait(10) #Check Page loader image and increase wait time if control.IsElementPresent( (By.XPATH, "//*[@id='divContent']/div[3]/img"), "Page Loading"): control.wait(30) #Displayed #validate Cross Search Results Section control.wait(10) #CrossSearchResults = [] CrossSearchResults = driver.find_element_by_xpath( "//div[@id='divContent']/div[@class='cross-search-parent-container']" ) control.wait(60) if CrossSearchResults.is_displayed( ) and not CrossSearchResults.text.find("No results"): control.ScrollToElementbyRef( CrossSearchResults, "Cross Search Results Section") control.wait(1) if CrossSearchResults.text.find("results for") and ( CrossSearchResults.text.find(strRootPart)): report.ReportHTMLLog( "Pass", f"Validate Cross Search Results for Part : {strRootPart}", f" Cross Search Results for Part : {strRootPart} has been displayed" ) report.CaptureScreenShot( f"Validate Cross Search Results for Part : {strRootPart}", screenshotpath) blnCrossSearchResultsFlag = True else: report.ReportHTMLLog( "Fail", f"Validate Cross Search Results for Part : {strRootPart}", f" Cross Search Results for Part : {strRootPart} has not been displayed" ) report.CaptureScreenShot( f"Validate Cross Search Results for Part : {strRootPart}", screenshotpath) #Assert.Fail("Validate Cross Search Results for Part : " + strRootPart, " Cross Search Results for Part : " + strRootPart + " has not been displayed"); self.Assert( f"Validate Cross Search Results for Part :{strRootPart}", f" Cross Search Results for Part : {strRootPart} has not been displayed" ) else: report.ReportHTMLLog( "Fail", f"Validate Cross Search Results for Part : {strRootPart}", f" Cross Search Results for Part : {strRootPart} has not been displayed" ) report.CaptureScreenShot( f"Validate Cross Search Results for Part : {strRootPart}", screenshotpath) self.assertIs( CrossSearchResults.is_displayed(), f"Validate Cross Search Results for Part :{strRootPart},Cross Search Results for Part : {strRootPart} has not been displayed" ) #//********************** Step 2 and 3 END : Enter "MAX232ACPE+" and Press "Enter" or Click Search icon ********************** # //********************** Step 4 START : Price/Unit field in search results ********************** if blnCrossSearchResultsFlag: #Get Part Number Fileds Count PartselementList = driver.find_elements_by_xpath( "//div[@class='crossref-part']/div/div[@class='col-md-3 col-sm-6']/span[@class='smallest' and text()='Part Number']" ) intPartsRowCnt = PartselementList.count() PartNumList = driver.find_elements_by_xpath( "//div[@class='crossref-part']/div/div[@class='col-md-3 col-sm-6']/p/a" ) if intPartsRowCnt >= 1: #//Differences Column Name Collections DifferencesColumnList = driver.find_elements_by_xpath( "//div[@class='crossref-part']/div/div[7][@class='col-md-2 col-sm-6']/span[@class='smallest']" ) intDifferencesListCnt = DifferencesColumnList.count() #Differences Column Value Collections DifferencesColumnValues = driver.find_elements_by_xpath( "//div[@class='crossref-part']/div/div[7][@class='col-md-2 col-sm-6']/p" ) #Differences Column Name and Value Validations for part_num in PartselementList: if part_num.text.__eq__(strSearchKeyWord): report.ReportHTMLLog( "Pass", f"Validate Cross Search Results Part Number : {part_num.text}", f" Validate Cross Search Results Part Number : {part_num.text} has been displayed" ) # ****************************** END ******************************** except Exception as ex: report.ReportHTMLLog("Fail", " Exception ", str(ex)) report.CaptureScreenShot("Exception ", screenshotpath) self.tearDown()
def search_part(reportfilepath, strMultiPartNums, strMultiNegativePartNums, screenshotpath): arrPartNums = str(strMultiPartNums).split(';') for strPartNum in arrPartNums: # Scrool to top of the page control.ScrollToTop() # control.ScrollToElement(driver, (By.LINK_TEXT, "ORDER"), "Scroll To Order") {TypeError}can only concatenate str (not "AttributeError") to str control.wait(1) # click on Order control.ClickLinkByText("ORDER", "ORDER") # click on SEARCH PRICE AND AVAILABILITY control.ClickLinkByText("SEARCH PRICE AND AVAILABILITY", "SEARCH PRICE AND AVAILABILITY") # CloseChatWindowIfExist # Action.CloseChatWindowIfExist() # Enter Part control.SetText((By.NAME, 'partSearchField'), strPartNum, 'PartNum') control.wait(1) report.CaptureScreenShot('step description', screenshotpath) # Click search control.ClickButton((By.ID, 'searchButton'), 'Search') control.wait(1) # Validate and click on view orderable parts if control.IsElementPresent( (By.XPATH, "//div[@class='purple uppercase smallest partOption pointer width160' and @href='javascript:void(0)']" ), '05'): control.wait(2) # if (driver.find_elements(By.XPATH, "//div/img[@class='partOptionImg rotate1']")):# partOptionImg rotate2 Already Expand the Item if (control.IsElementPresent( (By.XPATH, "//div/img[@class='partOptionImg rotate1']"), '10') ): # partOptionImg rotate2 Already Expand the Item control.ClickLink(( By.XPATH, "//div[@class='purple uppercase smallest partOption pointer width160' and @href='javascript:void(0)']" ), "View Orderable Parts") control.wait(1) # report.CaptureScreenShot('step description', screenshotpath) # elif (driver.find_elements(By.XPATH, "//div/img[@class='partOptionImg rotate2']")):# partOptionImg rotate2 Already Expand the Item elif (control.IsElementPresent( (By.XPATH, "//div/img[@class='partOptionImg rotate2']"), '10') ): # partOptionImg rotate2 Already Expand the Item control.wait(1) # report.CaptureScreenShot('step description', screenshotpath) else: report.ReportHTMLLog( "Fail", "View Orderable Parts", "View Orderable Parts are not displayed") # report.CaptureScreenShot('View Orderable Parts', screenshotpath) # Validate and Part num if control.IsElementPresent((By.LINK_TEXT, strPartNum), '10'): report.ReportHTMLLog("Pass", "Part num Search", strPartNum + " Part num is displayed ") report.CaptureScreenShot("Part num Search", screenshotpath) else: report.ReportHTMLLog( "Fail", "Part num Search", strPartNum + " Part num is not displayed ") report.CaptureScreenShot("Part num Search", screenshotpath) # GE.EndReport() # Assert.Fail(strPartNum + " Part num is not displayed ") # assertRaises(strPartNum + " Part num is not displayed ") # assert assert.ra arrNegativePartNums = str(strMultiNegativePartNums).split(';') for strNegativePartNum in arrNegativePartNums: # Scrool to top of the page control.ScrollToTop() # click on Order control.ClickLinkByText('ORDER', 'ORDER') # click on SEARCH PRICE AND AVAILABILITY control.ClickLinkByText("SEARCH PRICE AND AVAILABILITY", "SEARCH PRICE AND AVAILABILITY") # CloseChatWindowIfExist # Action.CloseChatWindowIfExist() # Enter Part control.SetText((By.NAME, 'partSearchField'), strNegativePartNum, 'PartNum') # Click search control.ClickButton((By.ID, 'searchButton'), 'Search') control.wait(2) report.CaptureScreenShot('step description', screenshotpath) # Validate and click on view orderable parts if control.CheckElementExistByPartialText( (By.XPATH, "//div/span[@class='bold']"), "Sorry, no results could be found", "Sorry, no results could be found"): report.ReportHTMLLog( "Pass", "Verify Part num Search Results", "Sorry, no results could be found for " + strPartNum + " is displayed Successfully ") report.CaptureScreenShot("Verify Part num Search Results", screenshotpath) else: report.ReportHTMLLog( "Fail", "Verify Part num Search Results", "Sorry, no results could be found for " + strPartNum + " is not displayed Successfully ") report.CaptureScreenShot("Verify Part num Search Results", screenshotpath)
def test_TC013_SXP_No_Maxim_Parts(self): try: global driver, imagename, imagecount, tc_execflag, qc_tester, qc_tc_exec_path, qc_ts_name appname = config.appname strCurrTestName = self._testMethodName.replace('test_', '').strip() # Initialize Report : base_url = config.base_url.strip() # Driver SetUp : implicitly_wait = config.implicitly_wait mobile_emulation = 'No' mobile_device = 'iPad' # iPhone 6/7/8 Plus,iPhone X,iPad,iPad Pro driver = drivers.setup(config.drivertype, config.driverpath, mobile_emulation, mobile_device, implicitly_wait) # read execution flag from Database DBData = dbutility(config.DB_Prod_Server, config.DB_Name, config.DB_Port, config.DB_User, config.DB_Prod_Pwd) tc_execflag, qc_tester, qc_tc_exec_path, qc_ts_name = DBData.ReadTCExecDetailsFromDB( appname, strCurrTestName) # Execution Flag If condition if tc_execflag.lower().strip() == 'Yes'.lower().strip(): testcasedescription = strCurrTestName # Initialize Report reportfilepath, screenshotpath = report.InitializeReport( config.ReportRootPath, strCurrTestName, testcasedescription) # Read Test Data SF_User = DBData.ReadParaValueFromDB(appname, strCurrTestName, "DT_SF_USER") SF_Password = DBData.ReadParaValueFromDB( appname, strCurrTestName, "DT_SF_PASSWORD") strPartNum = DBData.ReadParaValueFromDB( appname, strCurrTestName, "DT_PART_NUM") # ****************************** START ****************************** action.login(driver, reportfilepath, base_url, SXP_User, SXP_Password, screenshotpath) # Step 2 and 3 START : Enter "MAX232ACPE+" and Press "Enter" or Click Search icon # Set Search Text driver.find_element_by_id("cross-search-bar").send_keys( strPartNum) control.wait(1) report.CaptureScreenShot(f"Search KeyWord {strPartNum}", screenshotpath) # Click Search icon driver.find_element_by_id("cross-search-bar").click() control.wait(10) sText = driver.find_element_by_xpath( ".//*[@id='js-cross-reference-results']").text if str(sText).find("No results"): report.ReportHTMLLog( "Pass", "No results Validation", "No Results to show is displayed when there are no matching search" ) report.CaptureScreenShot("No results Validation", screenshotpath) # ****************************** END ******************************** except Exception as ex: report.ReportHTMLLog("Fail", " Test Script Exception ", f" Exception:{ex}") report.CaptureScreenShot(" ScreenShot at Test Script Exception ", screenshotpath) control.wait(2) self.tearDown() control.wait(2)
def TC012_SXP_Result_Table_Competitor_Part_Section_Rohs_Life_Cycle(self): try: global driver, imagename, imagecount, tc_execflag, qc_tester, qc_tc_exec_path, qc_ts_name appname = config.appname strCurrTestName = self._testMethodName.replace('test_', '').strip() # Initialize Report : base_url = config.base_url.strip() # Driver SetUp : implicitly_wait = config.implicitly_wait mobile_emulation = 'No' mobile_device = 'iPad' # iPhone 6/7/8 Plus,iPhone X,iPad,iPad Pro driver = drivers.setup(config.drivertype, config.driverpath, mobile_emulation, mobile_device, implicitly_wait) # read execution flag from Database DBData = dbutility(config.DB_Prod_Server, config.DB_Name, config.DB_Port, config.DB_User, config.DB_Prod_Pwd) tc_execflag, qc_tester, qc_tc_exec_path, qc_ts_name = DBData.ReadTCExecDetailsFromDB(appname, strCurrTestName) # ****************************** START ****************************** blnCrossSearchResultsFlag = False if tc_execflag.lower().strip() == 'Yes'.lower().strip(): testcasedescription = strCurrTestName # Initialize Report reportfilepath, screenshotpath = report.InitializeReport(config.ReportRootPath, strCurrTestName, testcasedescription) # Read Test Data SXP_User = DBData.ReadParaValueFromDB(appname, strCurrTestName, "DT_SXP_USER") SXP_Password = DBData.ReadParaValueFromDB(appname, strCurrTestName, "DT_SXP_PASSWORD") strRootPart = DBData.ReadParaValueFromDB(appname, strCurrTestName, "DT_ROOT_PART"); RootPartCompetitorName = DBData.ReadParaValueFromDB(strCurrTestName, "DT_ROOT_PART_COMPETITOR_NAME"); RootPartDescription = DBData.ReadParaValueFromDB(strCurrTestName, "DT_ROOT_PART_DESCRIPTION"); strLsColumnList = [] strLsColumnList.extend(str(StrColList).split(";")); strLsColumnValue = [] strLsColumnValue.extend(str(strColumnValues).split(';')); # ****************************** START ****************************** # Login and Login Validation action.login(driver, reportfilepath, base_url, SXP_User, SXP_Password, screenshotpath) # Step 2 and 3 START : Enter "MAX232ACPE+" and Press "Enter" or Click Search icon # Set Search Text driver.find_element_by_id("cross-search-bar").send_keys(strRootPart) control.wait(1) report.CaptureScreenShot(f"Search KeyWord {strRootPart}", screenshotpath) # Click Search icon driver.find_element_by_id("cross-search-bar").submit() control.wait(10) # Check Page loader image and increase wait time if control.IsElementPresent((By.XPATH, "//*[@id='divContent']/div[3]/img"), "Page Loading"): control.wait(30) # Displayed # validate Cross Search Results Section control.wait(10) # CrossSearchResults = [] CrossSearchResults = driver.find_element_by_xpath( "//div[@id='divContent']/div[@class='cross-search-parent-container']") control.wait(60) if CrossSearchResults.is_displayed() and not CrossSearchResults.text.find("No results"): control.ScrollToElementbyRef(CrossSearchResults, "Cross Search Results Section") control.wait(1) if CrossSearchResults.text.find("results for") and (CrossSearchResults.text.find(strRootPart)): report.ReportHTMLLog("Pass", f"Validate Cross Search Results for Part : {strRootPart}", f" Cross Search Results for Part : {strRootPart} has been displayed") report.CaptureScreenShot(f"Validate Cross Search Results for Part : {strRootPart}", screenshotpath) blnCrossSearchResultsFlag = True else: report.ReportHTMLLog("Fail", f"Validate Cross Search Results for Part : {strRootPart}", f" Cross Search Results for Part : {strRootPart} has not been displayed") report.CaptureScreenShot(f"Validate Cross Search Results for Part : {strRootPart}", screenshotpath) # Assert.Fail("Validate Cross Search Results for Part : " + strRootPart, " Cross Search Results for Part : " + strRootPart + " has not been displayed"); self.Assert(f"Validate Cross Search Results for Part :{strRootPart}", f" Cross Search Results for Part : {strRootPart} has not been displayed") else: report.ReportHTMLLog("Fail", f"Validate Cross Search Results for Part : {strRootPart}", f" Cross Search Results for Part : {strRootPart} has not been displayed") report.CaptureScreenShot(f"Validate Cross Search Results for Part : {strRootPart}", screenshotpath) self.assertIs(CrossSearchResults.is_displayed(), f"Validate Cross Search Results for Part :{strRootPart},Cross Search Results for Part : {strRootPart} has not been displayed") # //********************** Step 2 and 3 END : Enter "MAX232ACPE+" and Press "Enter" or Click Search icon ********************** # //********************** Step 4 START : Price/Unit field in search results ********************** if blnCrossSearchResultsFlag: CompetitorParts = driver.find_elements_by_xpath("//div[@class='crossref-part']/div[@id='CrossInfo']/div[@class='js-section-header col-lg-12 crossref-cross']") if(len(CompetitorParts) >= 1): for intPRowCnt, competiror_part in enumerate(CompetitorParts,start=0): #MAX232IN (Texas Instruments) if competiror_part.text == strRootPart + f" ({RootPartCompetitorName})\r\n{RootPartDescription}": report.ReportHTMLLog("Pass",f"Validate Results for Competitor Part : {strRootPart} Cross Search Results for Competitor Part : {strRootPart} has been displayed") report.CaptureScreenShot(f"Validate Cross Search Results for Competitor Part : {strRootPart}",ScreenShotPath) elif (intPRowCnt + 1) == len(CompetitorParts): report.ReportHTMLLog("Fail", f"Validate Results for Competitor Part : {strRootPart}", f" Cross Search Results for Competitor Part : {strRootPart} has not been displayed") Control.CaptureScreenShot(f"Validate Results for Competitor Part : {strRootPart}", screenshotpath) self.assertIs(not CrossSearchResults.is_displayed(),f"Validate Cross Search Results for Part :{strRootPart},Cross Search Results for Part : {strRootPart} has not been displayed") break else: report.ReportHTMLLog("Fail",f"Validate Cross Search Results Part Numbers for Part : {strRootPart}", f" Cross Search Results Part Numbers for Part : {strRootPart} are not been displayed") report.CaptureScreenShot(f"Validate Cross SearchResults Part Numbers for Part : {strRootPart}",screenshotpath) self.assertIs(len(CompetitorParts) == 0,f"Validate Cross Search Results Part Numbers for Part :{strRootPart}" , f" Cross Search Results Part Numbers for Part : {strRootPart} are not been displayed") # ****************************** END ******************************** except Exception as ex: report.ReportHTMLLog("Fail", " Exception ", str(ex)) report.CaptureScreenShot("Exception ", screenshotpath) self.tearDown()