public static void ClickContinueAndCapture() { Logger.AddClickAction("ContinueAndCapture"); SaveSearchGUID(); GetContinueButton().Click(); 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.", ExtrasPage.Data.HotelName)); } 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.", ExtrasPage.Data.HotelName)); } throw ex; } //capture screenshot //NonFunctionalReq.GetScreenShot("Hotel Booking Summary Page"); }
public static void ClickAvaliableRoomAndCapture(int availableRoom) { Logger.AddClickAction("AvailableRoomAndCapture", "AvailableRoom", availableRoom); IWebElement availableRoomButton = GetAvailableRoomButton(availableRoom); SaveHotelData(); SaveRoomData(currentRoomNumber, availableRoom); availableRoomButton.Click(); if (HomePage.Data.Rooms.Length == 1) { //capture time that takes to load summary page //ExtrasPage.WaitForLoad(); try { //capture time that takes to load summary page ExtrasPage.WaitForLoad(); } catch (Exception ex) { if (Driver.Instance.IsElementDisplayedBy(By.CssSelector("div div[class='alert alert-error']"))) { throw new Exception(String.Format("Room unavailable for checkin date:{1} to checkoutdate:{2} for Hotel {0}", HotelDetailPage.Data.HotelName, HomePage.Data.CheckInDate, HomePage.Data.CheckOutDate)); } if (Driver.Instance.IsElementDisplayedBy(By.CssSelector("div div[class='alert alert-warning']"))) { throw new Exception(String.Format("Hotel {0} unavailable for checkin date:{1} to checkoutdate:{2}", HotelDetailPage.Data.HotelName, HomePage.Data.CheckInDate, HomePage.Data.CheckOutDate)); } throw ex; } } }
//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 ClickContinue() { Logger.AddClickAction("Continue"); GetContinueButton().Click(); //capture time that takes to load summary page ExtrasPage.WaitForLoad(); }
public static void ClickContinueAndCapture() { Logger.AddClickAction("ContinueAndCapture"); GetContinueButton().Click(); //capture time that takes to load summary page ExtrasPage.WaitForLoad(); //capture screenshot //NonFunctionalReq.GetScreenShot("Extras Page"); }
public static void ClickAvaliableRoom(int availableRoom) { Logger.AddClickAction("AvailableRoom", "AvailableRoom", availableRoom); IWebElement availableRoomButton = GetAvailableRoomButton(availableRoom); SaveHotelData(); SaveRoomData(currentRoomNumber, availableRoom); availableRoomButton.Click(); if (HomePage.Data.Rooms.Length == 1) { //capture time that takes to load summary page ExtrasPage.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 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"); } }
internal static void WaitForLoad() { ExtrasPage.ResetData(); ExtrasPage.Data.LoadingTime = NonFunctionalReq.CaptureTime(() => Driver.Instance.FindElementWithTimeout(By.Id("extraspage"), 60, "Extras Page not loaded within 60 sec"), "Booking Summary page load time is"); }
public static bool IsExtraDisplayed(Extras extraName) { switch (extraName) { case Extras.HoldLuggage: try { Driver.Instance.FindElementWithTimeout(By.CssSelector("div#flightBaggageExtrasList[class='extra visible']"), 0, "Flight Baggage is not displayed"); return(true); } catch { return(false); } case Extras.FlightExtra: try { Driver.Instance.FindElementWithTimeout(By.CssSelector("div#flightExtrasList[class='extra visible']"), 0, "Flight Extra is not displayed"); return(true); } catch { return(false); } case Extras.AirportTransfer: try { ExtrasPage.WaitForLoad(); Driver.Instance.FindElementWithTimeout(By.CssSelector("div#transfersResults.ui-tabs-panel.ui-widget-content.ui-corner-bottom[aria-hidden = 'false']"), 30, "Airport Transfer Extra is not displayed"); return(true); } catch { return(false); } case Extras.Travelinsurance: try { Driver.Instance.FindElementWithTimeout(By.Id("extras-insurance"), 0, "Travel Insurrance is not displayed"); return(true); } catch { return(false); } case Extras.CarHire: try { Driver.Instance.FindElementWithTimeout(By.CssSelector("div#extras-carhire[class='extra visible']"), 0, "Car Hire Transfer Extra is not displayed"); return(true); } catch { return(false); } case Extras.AirportParking: try { Driver.Instance.FindElementWithTimeout(By.CssSelector("div#extras-airportparking[class='extra visible']"), 0, "Airport Parking Transfer Extra is not displayed"); return(true); } catch { return(false); } } return(false); }