def searchforFlight(): element = driver.find_element_by_xpath( ".//*[@id='flightOneWayFromInput' or @id='flightReturnFromInput']") element.send_keys(baseBrowser.DCITY) baseScript.timeInterval(3) element.send_keys("\t") element = driver.find_element_by_xpath(".//*[@name='to']") element.send_keys(baseBrowser.ACITY) baseScript.timeInterval(3) element.send_keys("\t") element = driver.find_element_by_xpath( ".//*[@id='startOneWay' or @id='start']/input") element.send_keys(baseBrowser.DDate) baseScript.timeInterval(3) element.send_keys("\t") if (baseScript.display_element("xpath", ".//*[@id='end']/input")): element = driver.find_element_by_xpath(".//*[@id='end']/input") element.clear() element.send_keys(baseBrowser.ADate) baseScript.timeInterval(3) element.send_keys("\t") baseScript.click('xpath', ".//*[@class='available-btns']") baseScript.timeInterval(2) baseScript.waitForElement( ".// div[ @class ='row in-page-search-header'] // p[starts-with(text(), '{}')]" .format(Constant.FlightSearch_ResultsExpireMsg))
def performAction(actionName): baseScript.timeInterval(2) baseScript.click("xpath", ".//*[contains(@id,'{}')]".format(actionName)) baseScript.timeInterval(1) baseScript.waitForElement( ".//*[@id='secondary-tabs']//a[text()='{}']".format( Constant.Dashboard_OneWay))
def test_scenario01(): baseBrowser.loadbrowser() print("Verify Logo") assert True == homePage.verifyLogo() print("Verify Menu") assert True == homePage.verifyHeaderMenu() print("Verify Homepage Content") assert True == homePage.verifyHomepageContent() assert True == homePage.verifyFooter() baseScript.timeInterval(2)
def searchForFlight(DAirport, AAirport, DDate, ADate): element = driver.find_element_by_xpath( ".//*[@id='flightOneWayFromInput' or @id='flightReturnFromInput']") baseScript.sendKeys( 'xpath', ".//*[@id='flightOneWayFromInput' or @id='flightReturnFromInput']", DAirport) baseScript.timeInterval(3) element.send_keys("\t") element = driver.find_element_by_xpath(".//*[@name='to']") baseScript.sendKeys('xpath', ".//*[@name='to']", AAirport) baseScript.timeInterval(3) element.send_keys("\t") element = driver.find_element_by_xpath( ".//*[@id='startOneWay' or @id='start']/input") baseScript.sendKeys('xpath', ".//*[@id='startOneWay' or @id='start']/input", DDate) baseScript.timeInterval(3) element.send_keys("\t") if (baseScript.display_element("xpath", ".//*[@id='end']/input")): element = driver.find_element_by_xpath(".//*[@id='end']/input") element.clear() baseScript.sendKeys('xpath', ".//*[@id='end']/input", ADate) baseScript.timeInterval(3) element.send_keys("\t")
def verifyUserAction(): baseScript.click("xpath", ".//div[@class='profile-block']") myProfile = baseScript.display_element( "xpath", ".//div[@class='dropdown profile ng-isolate-scope']//a[normalize-space(.)='{}']" .format(Constant.Banner_MyProfile)) baseScript.timeInterval(2) singout = baseScript.display_element( "xpath", ".//div[@class='dropdown profile ng-isolate-scope']//a[normalize-space(.)='{}']" .format(Constant.Banner_SignOut)) baseScript.timeInterval(2) baseScript.click("xpath", ".//div[@class='profile-block active']") if (myProfile and singout): return True else: return False
def verifyDashboardContent1(): baseScript.timeInterval(2) heading = baseScript.display_element( "xpath", ".//h1[text()='Welcome to VacationChamp']") flight = baseScript.display_element("xpath", ".//*[contains(@id,'flight')]") baseScript.timeInterval(2) hotel = baseScript.display_element("xpath", ".//*[contains(@id,'hotel')]") baseScript.timeInterval(2) rent = baseScript.display_element("xpath", ".//*[contains(@id,'rental')]") baseScript.timeInterval(2) car = baseScript.display_element("xpath", ".//*[contains(@class,'car ')]") commingSoon = baseScript.display_element( "xpath", ".//div[starts-with(@class,'option car')]//div[normalize-space(.)='Coming Soon']" ) baseScript.timeInterval(1) if heading and flight and hotel and rent and car and commingSoon: return True else: return False
def test_scenario01(): print("Scenario 01 : Verify action to click on Back link or icon") print("Load Browser successfully") baseScript.timeInterval(10) baseBrowser.loadbrowser() print("Precondition : User should be logged In and on the Dashboard Page.") login.forLogin(baseBrowser.USERNAME, baseBrowser.PASSWORD) print("Steps: ") print("=======================") print("1.Click on Flight navigation icon") dashbord.performAction("flight") print("2.Click on Back link or icon") searchFlight.navigateBack() baseBrowser.expectedResult() expectedResult = dashbord.verifyDashboardContent1() if (expectedResult): print("PASS") else: print("FAIL") print("User is not redirected back to the Home Page.") assert True == expectedResult print("User is redirected back to the Home Page.")
def verifyFooter(): return baseScript.display_element( "xpath", ".//footer[@class='global-footer purple']") baseScript.timeInterval(2)
def verifyHomepageContent(): baseScript.timeInterval(2) heading = baseScript.display_element( "xpath", ".//h1[text()='Welcome to VacationChamp']") flight = baseScript.display_element("xpath", ".//*[contains(@id,'flight')]") baseScript.timeInterval(2) hotel = baseScript.display_element("xpath", ".//*[contains(@id,'hotel')]") baseScript.timeInterval(2) rent = baseScript.display_element("xpath", ".//*[contains(@id,'rental')]") baseScript.timeInterval(2) car = baseScript.display_element("xpath", ".//*[contains(@class,'car ')]") driver.execute_script("window.scrollBy(0,500);") title = baseScript.display_element("xpath", ".//*[@id='about']/h1") baseScript.timeInterval(2) first = baseScript.display_element( "xpath", ".//*[@id='about']//h2[text()='{}']".format( Constant.Home_RightProductRightTime)) baseScript.timeInterval(2) second = baseScript.display_element( "xpath", ".//*[@id='about']//h2[text()='{}']".format( Constant.Home_TheSearchIsOver)) baseScript.timeInterval(2) driver.execute_script("window.scrollBy(0,500);") third = baseScript.display_element( "xpath", ".//*[@id='about']//h2[text()='{}']".format( Constant.Home_EveryAspectOfYourTripIsHere)) baseScript.timeInterval(2) forth = baseScript.display_element( "xpath", ".//*[@id='about']//h2[text()='{}']".format( Constant.Home_DontEmailLinksShareInspiration)) driver.execute_script("window.scrollBy(0,document.body.scrollHeight);") if heading and flight and hotel and rent and car and title and first and second and third and forth: return True else: return False
def signOut(): baseScript.click("XPATH", ".//div[starts-with(@class,'profile-block')]") baseScript.timeInterval(3) baseScript.click( "XPATH", ".//*[@id='logoutForm']/a[text()='{}']".format( Constant.Banner_SignOut))
def gotoOneWayForm(): baseScript.timeInterval(2) baseScript.click( "xpath", ".//*[@id='secondary-tabs']//a[text()='{}']".format( Constant.Dashboard_OneWay)) baseScript.timeInterval(2)
def navigateBack(): baseScript.timeInterval(2) #baseScript.click('xpath', ".//*[@id='backG']/text/tspan") baseScript.driver.back() baseScript.waitForElement(".//*[@id='trigger-flight']")
def clickOnWhatsAvailableNowBtn(): baseScript.click('xpath', ".//*[@class='available-btns']") baseScript.timeInterval(2) baseScript.waitForElement( ".// div[ @class ='row in-page-search-header'] // p[starts-with(text(), '{}')]" .format(Constant.FlightSearch_ResultsExpireMsg))
def verifyDashboardContent2(): #driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") driver.execute_script("window.scrollBy(0,500);") baseScript.timeInterval(2) title = baseScript.display_element( "xpath", ".//section[@class='recent-activity bg-blurple ng-scope']//div[@class='title']" ) #driver.execute_script("window.scrollIntoView();", ".//section[@class='recent-activity bg-blurple ng-scope']//div[@class='title']") baseScript.timeInterval(2) instantBooking = baseScript.display_element( "xpath", ".//*[@class='spaced-out blurple' and text()='{}']".format( Constant.Dashboard_InstantBookings)) baseScript.timeInterval(2) recentSearch = baseScript.display_element( "xpath", ".//*[@class='spaced-out blurple' and text()='{}']".format( Constant.Dashboard_RecentSearches)) driver.execute_script("window.scrollBy(0,500);") baseScript.timeInterval(2) continousSearch = baseScript.display_element( "xpath", ".//*[@class='medium blurple' and text()='{}']".format( Constant.Dashboard_ContinuousSearches)) baseScript.timeInterval(2) myRequest = baseScript.display_element( "xpath", ".//*[@class='spaced-out blurple' and text()='{}']".format( Constant.Dashboard_MyRequests)) baseScript.timeInterval(2) saveCollection = baseScript.display_element( "xpath", ".//*[@class='medium blurple' and text()='{}']".format( Constant.Dashboard_RecentlySavedToCollections)) baseScript.timeInterval(2) recentBooking = baseScript.display_element( "xpath", ".//*[@class='medium blurple' and text()='{}']".format( Constant.Dashboard_RecentBookings)) driver.execute_script("window.scrollBy(0,500);") if title and instantBooking and recentSearch and continousSearch and myRequest and saveCollection and recentBooking: return True else: return False
def verifyFooter(): baseScript.timeInterval(2) return baseScript.display_element("xpath", ".//*[@class='global-footer']")