コード例 #1
0
 public void Continue()
 {
     foreach (Room room in this.rooms)
     {
         if (this.rooms.IndexOf(room) > 0)
         {
             EstablishmentPage.SelectRoomTab(room.roomNumber);
             if (room.availableRoomNumber != 0)
             {
                 EstablishmentPage.SelectRoomByNumber(room.availableRoomNumber);
             }
             Driver.WaitForAjax();
             Driver.Wait(TimeSpan.FromSeconds(1));
             EstablishmentPage.ClickContinueButton();
             try
             {
                 PageFunctions.WaitForLoad("agentpaymentpage", "Payment page not displayed in 40 secs");
             }
             catch (Exception ex)
             {
                 Guids.SearchGuid = PageFunctions.GetSearchGUID();
                 Guids.pageUrl    = PageFunctions.GetUrl();
                 ReadOnlyCollection <IWebElement> ErrMsgsDivs = Driver.Instance.FindElements(By.CssSelector("div.box-header h4.box-heading"));
                 IWebElement displayedErrMsg;
                 try
                 {
                     displayedErrMsg = ErrMsgsDivs.First(i => i.Displayed);
                 }
                 catch
                 {
                     throw ex;
                 }
                 if (displayedErrMsg.Text.Trim() == "Hotel unavailable")
                 {
                     throw new Exception(string.Format("Selected Hotel room(s) are fully booked for the dates selected."));
                 }
                 if (displayedErrMsg.Text.Trim() == "No results found")
                 {
                     throw new Exception(string.Format("For Selected Hotel 'No results found' error message is displayed."));
                 }
                 if (displayedErrMsg.Text.Trim() == "Room unavailable")
                 {
                     throw new Exception(string.Format("For Room Number {0} selected room {1} is no longer available.", room.roomNumber, room.availableRoomNumber));
                 }
                 throw ex;
             }
         }
         else
         {
             if (room.availableRoomNumber != 0)
             {
                 EstablishmentPage.SelectRoomByNumber(room.availableRoomNumber);
             }
         }
     }
 }
コード例 #2
0
        public void Search()
        {
            if (destination != null)
            {
                HomePage.TypeDestination(this.destination, this.IsHotel);
            }

            if (fromDate != null)
            {
                HomePage.SelectCheckIn(this.fromDate);
            }

            if (toDate != null)
            {
                HomePage.SelectCheckOut(toDate);
            }

            PassangerPopUpBox.Open();

            foreach (Room room in this.rooms)
            {
                if (this.rooms.IndexOf(room) > 0)
                {
                    PassangerPopUpBox.ClickAddAnotherRoom();
                }
                if (room.noOfAdults != 0)
                {
                    PassangerPopUpBox.SelectAdults(room.noOfAdults, this.rooms.IndexOf(room));
                }
                if (room.noOfChildren != 0)
                {
                    PassangerPopUpBox.SelectChildren(room.noOfChildren, room.childrenAges, this.rooms.IndexOf(room));
                }
            }

            PassangerPopUpBox.SaveChanges();

            HomePage.ClickSearchButton();

            if (IsHotel)
            {
                try
                {
                    PageFunctions.WaitForLoad("establishmentpage", "Establishment page not displayed in 40 secs");
                }
                catch (Exception ex)
                {
                    ReadOnlyCollection <IWebElement> ErrMsgsDivs = Driver.Instance.FindElements(By.CssSelector("div.box-header h4.box-heading"));
                    IWebElement displayedErrMsg;
                    try
                    {
                        displayedErrMsg = ErrMsgsDivs.First(i => i.Displayed);
                    }
                    catch
                    {
                        throw ex;
                    }
                    if (displayedErrMsg.Text.Trim() == "Hotel unavailable")
                    {
                        throw new Exception(string.Format("Selected Hotel {0} is fully booked for the dates {1} to {2}.", this.destination, this.fromDate, this.toDate));
                    }
                    if (displayedErrMsg.Text.Trim() == "No results found")
                    {
                        throw new Exception(string.Format("For Selected Hotel {0} between {1} to {2} dates 'No results found' error message is displayed.", this.destination, this.fromDate, this.toDate));
                    }
                    throw ex;
                }
            }
            else
            {
                try
                {
                    PageFunctions.WaitForLoad("accommodationresultspage", "Accommodation result page not displayed in 40 secss");
                }
                catch (Exception ex)
                {
                    ReadOnlyCollection <IWebElement> ErrMsgsDivs = Driver.Instance.FindElements(By.CssSelector("div.box-header h4.box-heading"));
                    IWebElement displayedErrMsg;
                    try
                    {
                        displayedErrMsg = ErrMsgsDivs.First(i => i.Displayed);
                    }
                    catch
                    {
                        throw ex;
                    }
                    displayedErrMsg = ErrMsgsDivs.First(i => i.Displayed);
                    if (displayedErrMsg.Text.Trim() == "No results found")
                    {
                        throw new Exception(string.Format("For Selected destination {0} between {1} to {2} dates 'No results found' error message is displayed.", this.destination, this.fromDate, this.toDate));
                    }
                    throw ex;
                }
            }
        }