public static void ClickSearch() { Logger.AddClickAction("Search"); //click search button GetSearchButton().Click(); //capture the page load time HomePage.Data.SearchTime = NonFunctionalReq.CaptureTime(() => Driver.Instance.FindElementWithTimeout(By.CssSelector("div.row-fluid a.pull-left div.logo"), 65, "Result page is not displayed within 60 Sec"), "Search Page load time is"); switch (HomePage.Data.SearchOption) { case SearchOption.FlightOnly: //Wait for java script to load FlightResultsPage.WaitToLoad(); break; case SearchOption.HotelOnly: //Wait for java script to load HotelResultsPage.WaitToLoad(); break; case SearchOption.FlightAndHotel: //Wait for java script to load FlightResultsPage.WaitToLoad(); break; } }
//Select enviorment to run the automation tests public static void Navigate(TestEnvironment Env) { switch (Env) { case TestEnvironment.Live: //Capture Page Load Times NonFunctionalReq.CaptureTime(() => Driver.Instance.Navigate().GoToUrl("https://www.alpharooms.com"), "Landing Page load time is"); break; case TestEnvironment.Staging: //Capture Page Load Times NonFunctionalReq.CaptureTime(() => Driver.Instance.Navigate().GoToUrl("https://no.staging.alpharooms.com/"), "Landing Page load time is"); break; case TestEnvironment.QA: //Capture Page Load Times NonFunctionalReq.CaptureTime(() => Driver.Instance.Navigate().GoToUrl("http://flightshotfix.alpha2.com/"), "Landing Page load time is"); break; case TestEnvironment.SOAFlights: //Capture Page Load Times NonFunctionalReq.CaptureTime(() => Driver.Instance.Navigate().GoToUrl("http://flights3.alpha2.com/"), "Landing Page load time is"); break; } Logger.Clear(); HomePage.ResetData(); FlightResultsPage.ResetData(); HotelResultsPage.ResetData(); HotelDetailPage.ResetData(); ExtrasPage.ResetData(); InsurancePage.ResetData(); PaymentPage.ResetData(); }
public static void ClickHotelNumber(int hotelNumber) { SaveSearchGUID(); SaveTotalSearchResultsFlightsHotel(); if (hotelNumber < 1) { throw new ArgumentOutOfRangeException("hotelNumber", hotelNumber, "The hotel number must be 1 or higher."); } Logger.AddClickAction("HotelNumber", "HotelNumber", hotelNumber); HotelResultsPage.SaveHotelData(hotelNumber); var hotelPanel = GetHotelPanel(hotelNumber); var hotelNameLink = hotelPanel.FindElement(By.CssSelector("div.establishment-header h2.establishment-heading a")); hotelNameLink.Click(); HotelDetailPage.WaitForLoad(); }
public static void ClickFlightAndCapture(int flightNumber) { if (flightNumber < 1) { throw new ArgumentOutOfRangeException("flightNumber", flightNumber, "The flight number must be 1 or higher."); } Logger.AddClickAction("FlightAndCapture", "FlightNumber", flightNumber); SaveSearchGUID(); SaveFlightData(flightNumber); IWebElement flightBookNowBtn = GetAvailableFlightButton(flightNumber); NonFunctionalReq.ExecuteAndRetry(() => flightBookNowBtn.Click(), "Selected flight is Ryanair."); //capture screenshot try { if (HomePage.Data.SearchOption == SearchOption.FlightOnly) { ExtrasPage.WaitForLoad(); //capture screenshot //NonFunctionalReq.GetScreenShot("Hotel Booking Summary Page"); } else if (HomePage.Data.SearchOption == SearchOption.FlightAndHotel) { HotelResultsPage.WaitToLoad(); //capture screenshot //NonFunctionalReq.GetScreenShot("Hotel Booking Summary Page"); } } catch (Exception ex) { if (Driver.Instance.IsElementDisplayedBy(By.CssSelector("div.alert h4"))) { throw new Exception(string.Format("Flight Number {0} is no longer available.", flightNumber)); } if (Driver.Instance.IsElementDisplayedBy(By.Id("search-timeout"))) { throw new Exception(string.Format("Sun Error Page is displayed for Flight Number {0}", flightNumber)); } throw ex; } }
public static void ClickHotelNumberAndCapture(int hotelNumber) { SaveSearchGUID(); if (hotelNumber < 1) { throw new ArgumentOutOfRangeException("hotelNumber", hotelNumber, "The hotel number must be 1 or higher."); } Logger.AddClickAction("HotelNumberAndCapture", "HotelNumber", hotelNumber); HotelResultsPage.SaveHotelData(hotelNumber); var hotelPanel = GetHotelPanel(hotelNumber); var hotelNameLink = hotelPanel.FindElement(By.CssSelector("h3.hotel-name a")); hotelNameLink.Click(); HotelDetailPage.WaitForLoad(); //capture screenshot //NonFunctionalReq.GetScreenShot("Hotel Booking Summary Page"); }
public static void ClickAvailableRoomAndCapture(int hotelNumber, int availableRoom) { if (hotelNumber < 1) { throw new ArgumentOutOfRangeException("hotelNumber", hotelNumber, "The hotel number must be 1 or higher."); } if (availableRoom < 1) { throw new ArgumentOutOfRangeException("availableRoom", availableRoom, "availableRoom must be 1 or higher."); } Logger.AddClickAction("AvailableRoomAndCapture", "HotelNumber", hotelNumber, "AvailableRoom", availableRoom); HotelResultsPage.SaveHotelData(hotelNumber); var selectRoomLink = GetAvailableRoomButton(hotelNumber, availableRoom); SaveSearchGUID(); SaveTotalSearchResults(); SaveRoomData(hotelNumber, currentRoomNumber, availableRoom); selectRoomLink.Click(); if (HomePage.Data.Rooms.Length == 1) { try { //capture time that takes to load summary page ExtrasPage.WaitForLoad(); } catch (Exception ex) { if (Driver.Instance.IsElementDisplayedBy(By.CssSelector("div.alert h4[class='alert alert-error hidden']"))) { throw new Exception(string.Format("Hotel Number {0} selected room is no longer available.", hotelNumber)); } if (Driver.Instance.IsElementDisplayedBy(By.CssSelector("div.alert h4[class='alert alert-warning hidden']"))) { throw new Exception(string.Format("Hotel Number {0} is fully booked for the dates selected.", hotelNumber)); } throw ex; } //capture screenshot //NonFunctionalReq.GetScreenShot("Hotel Booking Summary Page"); } }
public static void ClickRoomNumber(int hotelNumber, int roomNumber) { if (hotelNumber < 1) { throw new ArgumentOutOfRangeException("hotelNumber", hotelNumber, "The hotel number must be 1 or higher."); } if (roomNumber < 1) { throw new ArgumentOutOfRangeException("roomNumber", roomNumber, "The room number must be 1 or higher."); } Logger.AddClickAction("RoomNumber", "HotelNumber", hotelNumber, "RoomNumber", roomNumber); currentRoomNumber = roomNumber; HotelResultsPage.Data.EnsureCapacity(roomNumber); HotelResultsPage.SaveHotelData(hotelNumber); var hotelPanel = GetHotelPanel(hotelNumber); var selectedRoom = hotelPanel.FindElement(By.Id(string.Format("estab{0}-room-tab{1}", hotelNumber - 1, roomNumber))); selectedRoom.Click(); Driver.Instance.WaitForAjax(); Thread.Sleep(500); }
public static void ClickSearchAndCapture() { Logger.AddClickAction("SearchAndCapture"); //click search button GetSearchButton().Click(); //capture the page load time HomePage.Data.SearchTime = NonFunctionalReq.CaptureTime(() => Driver.Instance.FindElementWithTimeout(By.Id("filtersDialog"), 60, "Result page is not displayed within 60 Sec"), "Search Page load time is"); switch (HomePage.Data.SearchOption) { case SearchOption.FlightOnly: //Wait for java script to load FlightResultsPage.WaitToLoad(); //capture screenshot //NonFunctionalReq.GetScreenShot("Hotel Booking Summary Page"); break; case SearchOption.HotelOnly: //Wait for java script to load HotelResultsPage.WaitToLoad(); //capture screenshot //NonFunctionalReq.GetScreenShot("Hotel Booking Summary Page"); break; case SearchOption.FlightAndHotel: //Wait for java script to load FlightResultsPage.WaitToLoad(); //capture screenshot //NonFunctionalReq.GetScreenShot("Hotel Booking Summary Page"); break; } }
internal static void WaitToLoad() { HotelResultsPage.ResetData(); HotelResultsPage.Data.LoadingTime = NonFunctionalReq.CaptureTime(() => Driver.Instance.WaitForAjax(), "Hotel Result Page Rendering Time"); }