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 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 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 verifyMenu(): mytrip = baseScript.display_element( "xpath", ".//ul[@class='nav-left']//a[normalize-space(.)='{}']".format( Constant.Dashboard_MyTrips)) inbox = baseScript.display_element( "xpath", ".//ul[@class='nav-left']//a[normalize-space(.)='{}']".format( Constant.Dashboard_Inbox)) collection = baseScript.display_element( "xpath", ".//ul[@class='nav-left']//a[normalize-space(.)='{}']".format( Constant.Dashboard_Collections)) profile = baseScript.display_element( "xpath", ".//ul[@class='nav-left']//a[normalize-space(.)='{}']".format( Constant.Dashboard_Profile)) if mytrip and inbox and collection and profile: return True else: return False
def validation(error_message): print("Observe Validation Message") time.sleep(2) print(".//*[@id='frmLogin']/div[text()='{}']".format(error_message)) #print(".//*[@id='frmOk']/div[normalize-space(.)='{}']".format(error_message)) driver.get_screenshot_as_png() driver.save_screenshot(Constant.ScreenShotPath) return baseScript.display_element( 'XPATH', ".//*[@id='frmLogin']/div[text()='{}']".format(error_message))
def verifyHeaderMenu(): about = baseScript.display_element( "xpath", ".//ul[@class='nav-left']//a[normalize-space(.)='{}']".format( Constant.Home_About)) list = baseScript.display_element( "xpath", ".//ul[@class='nav-left']//a[normalize-space(.)='{}']".format( Constant.Home_List)) news = baseScript.display_element( "xpath", ".//ul[@class='nav-left']//a[normalize-space(.)='{}']".format( Constant.Home_News)) register = baseScript.display_element( "xpath", ".//ul[@class='nav-right']//a[normalize-space(.)='{}']".format( Constant.Home_Register)) request = baseScript.display_element( "xpath", ".//ul[@class='nav-right']//a[normalize-space(.)='{}']".format( Constant.Home_RequestAnInvite)) signIn = baseScript.display_element( "xpath", ".//ul[@class='nav-right']//a[normalize-space(.)='{}']".format( Constant.Banner_SignIn)) if about and list and news and register and request and signIn: return True else: return False
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 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 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 loginUserName(loginusername): username = baseScript.display_element( "XPATH", ".//*[@class='name ng-binding' and text()='{}']".format(loginusername)) return username
def verifyLogo(): return baseScript.display_element( "xpath", "././/div[@class='logo']//img [@src='/Content/assets/img/site-logo.png']" )
def varifyRequiredFieldMsg(): return baseScript.display_element( "xpath", ".//div[text()='{}']".format(Constant.RequiredFieldMsg))
def verifyReturnDate(): return baseScript.display_element("ID", "end")
def verifyLogo(): return baseScript.display_element( "xpath", ".//a[@alt='Go to home page']/img[@src='/Content/assets/img/Logo.png']" )
def verifyLoginUser(username): #return baseScript.display_element("xpath",".//div[@class='profile-block']//p{}".format(username)) return baseScript.display_element( "xpath", ".//div[@class='profile-block']//p[text()='{}']".format(username))
def verifyFooter(): return baseScript.display_element( "xpath", ".//footer[@class='global-footer purple']") baseScript.timeInterval(2)
def verifyFooter(): baseScript.timeInterval(2) return baseScript.display_element("xpath", ".//*[@class='global-footer']")