コード例 #1
0
        public void SelectResource()
        {
            LoginMain login = new LoginMain(this.driver);

            SearchResource();
            Thread.Sleep(2000);
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
            try
            {
                this.Map.exactmatch.Click();
            }
            catch (WebDriverException e)
            {
                IList <IWebElement>       selectElements = driver.FindElements(By.ClassName("available"));
                IEnumerator <IWebElement> enumerator     = selectElements.GetEnumerator();
                bool hasNext = enumerator.MoveNext();
                while (hasNext)
                {
                    IWebElement i = enumerator.Current;
                    login.Wait();
                    i.Click();
                    login.Wait();
                    if (this.Map.resourceselected.Displayed)
                    {
                        break;
                    }
                    else
                    {
                        hasNext = enumerator.MoveNext();
                    }
                }
                enumerator.Dispose();

                Console.WriteLine("Exact match was not Found, but other available time was selected");
            }
        }
コード例 #2
0
 public void AddServicesButtonCheck()
 {
     utilities.ConsoleMessageStart();
     utilities.extenttest = utilities.extent.StartTest("Add Services Button Check");
     utilities.extenttest.AssignCategory("Services Tests");
     login.NavigateTo();
     login.LoginSuccess();
     Thread.Sleep(3000);
     homepage.SelectResource();
     login.Wait();
     services.AddServicesButton();
     login.Wait();
     Assert.IsTrue(this.driver.FindElement(By.XPath("//*[@id='step3AddServices']")).Displayed);
     utilities.extenttest.Log(LogStatus.Pass, "Assert pass ");
 }
コード例 #3
0
        public void BookingDurationValidation()
        {
            utilities.ConsoleMessageStart();
            utilities.extenttest = utilities.extent.StartTest("Booking Duration Validation");
            utilities.extenttest.AssignCategory("HomePage Tests");
            login.NavigateTo();
            login.LoginSuccess();
            //Thread.Sleep(4000);
            login.Wait();
            homepage.SearchResource();
            // Thread.Sleep(2000);
            login.Wait();
            var Time = this.Map.exactmatchtime.Text;

            Console.WriteLine("Time: " + Time);
            string StartTime = Time.Substring(0, Time.IndexOf("-"));

            Console.WriteLine("Start Time: " + StartTime);
            string FinishTime = Time.Substring(Time.IndexOf("-") + 2);

            Console.WriteLine("Finish Time: " + FinishTime);
            string finishtimehoursplit = FinishTime.Substring(0, FinishTime.IndexOf(":"));

            Console.WriteLine("Finish Time Split: " + finishtimehoursplit);
            int finishtimehourint = Convert.ToInt32(finishtimehoursplit);

            Console.WriteLine("FT: " + finishtimehourint);
            string starttimehoursplit = StartTime.Substring(0, StartTime.IndexOf(":"));

            Console.WriteLine("Start Time split: " + starttimehoursplit);
            int starttimehourint = Convert.ToInt32(starttimehoursplit);

            Console.WriteLine("Start Time Hour in Int: " + starttimehourint);
            int Hoursum = 0;

            if ((FinishTime.Contains("pm") && !FinishTime.Contains("12")) && ((StartTime.Contains("am")) && !StartTime.Contains("12")))
            {
                Hoursum = (12 + finishtimehourint) - starttimehourint;
            }
            else if ((FinishTime.Contains("am") || FinishTime.Contains("12")) && (StartTime.Contains("am")))
            {
                Hoursum = finishtimehourint - starttimehourint;
            }
            else if (StartTime.Contains("pm"))
            {
                Hoursum = (12 + finishtimehourint) - (12 + starttimehourint);
            }
            else if ((FinishTime.Contains("pm") && !FinishTime.Contains("12")) && ((StartTime.Contains("am")) && StartTime.Contains("12")))
            {
                Hoursum = (12 + finishtimehourint);
            }

            Console.WriteLine("SUM: " + Hoursum);

            Console.WriteLine("---------------------------------------------");
            //Minutes Starts here

            string finishtimeminutesplit = FinishTime.Substring(FinishTime.IndexOf(":") + 1);

            Console.WriteLine("Finish Time Minute Split: " + finishtimeminutesplit);
            string finishtimeminutesplitpm = finishtimeminutesplit.Substring(0, 2);

            Console.WriteLine("Finish Time Minute Split PM : " + finishtimeminutesplitpm);
            int finishtimeminuteint = Convert.ToInt32(finishtimeminutesplitpm);

            Console.WriteLine("Finish Time Minute in Int: " + finishtimeminuteint);
            string starttimeminutesplit = StartTime.Substring(StartTime.IndexOf(":") + 1);

            Console.WriteLine("Start Time Minutesplit: " + starttimeminutesplit);
            string starttimeminutesplitpm = starttimeminutesplit.Substring(0, 2);

            Console.WriteLine("Start Time Minute Split PM : " + starttimeminutesplitpm);
            int starttimeminuteint = Convert.ToInt32(starttimeminutesplitpm);

            Console.WriteLine("Start Time Minute in Int: " + starttimeminuteint);
            Console.WriteLine("---------------------------------------------");

            int minutesum = 0;

            if ((finishtimeminutesplitpm.Contains("00")) && ((starttimeminutesplitpm.Contains("15")) || (starttimeminutesplitpm.Contains("30") || (starttimeminutesplitpm.Contains("45")))))
            {
                minutesum = (60 - starttimeminuteint);
                Console.WriteLine(minutesum);
            }
            else if (starttimeminuteint < finishtimeminuteint)
            {
                minutesum = finishtimeminuteint - starttimeminuteint;
                Console.WriteLine("Running second if : " + minutesum);
            }
            //else if ((starttimeminutesplitpm.Equals("00") && (finishtimeminutesplitpm.Contains("00"))))
            else if (starttimeminutesplitpm == finishtimeminutesplitpm)
            {
                minutesum = finishtimeminuteint - starttimeminuteint;
                Console.WriteLine("Running Third if : " + minutesum);
            }
            else if (starttimeminuteint > finishtimeminuteint)
            {
                minutesum = 60 + (finishtimeminuteint - starttimeminuteint);
                Console.WriteLine("Running Fourth if : " + minutesum);
            }

            Console.WriteLine("---------------------------------------------");
            Console.WriteLine("Final Minute : " + minutesum);

            Console.WriteLine("---------------------------------------------");

            string Finalminutes = "";

            if (minutesum < 15)
            {
                Finalminutes = "0" + minutesum;
                Console.WriteLine("Final minutes with Zero added in  Front :" + Finalminutes);
            }
            else
            {
                Finalminutes = minutesum.ToString();
                Console.WriteLine("Final Minute :" + Finalminutes);
            }

            if (starttimeminuteint > finishtimeminuteint)
            {
                Hoursum = Hoursum - 1;
            }

            Console.WriteLine("Hour Sum = " + Hoursum);

            Console.WriteLine("---------------------------------------------");

            string Finalduration = Hoursum + "." + Finalminutes;

            Console.WriteLine("Final Duration = " + Finalduration);

            var selecteddur = this.Map.Duration.GetAttribute("value");

            Console.WriteLine("Selected Duration = " + selecteddur);

            Assert.IsTrue(Finalduration.Equals(selecteddur));
            utilities.extenttest.Log(LogStatus.Pass, "Assert pass ");
        }
コード例 #4
0
        public void Case3615()
        {
            utilities.ConsoleMessageStart();
            utilities.extenttest = utilities.extent.StartTest("TFS Case 3615 Cancel Popup not displaying properly");
            utilities.extenttest.AssignCategory("Case 3615. Cancel Popup");
            login.NavigateTo();
            login.LoginSuccess();
            Thread.Sleep(4000);
            homepage.SelectResource();
            login.Wait();
            attendees.AddingInternalAttendee();
            Thread.Sleep(2000);
            homepage.NextButton();
            Thread.Sleep(2000);
            booking.BookingTitle();
            var refnumber = this.driver.FindElement(By.XPath("//*[@id='page-wrap']/section[2]/div[1]/div/div[3]/span")).Text;

            Console.WriteLine(refnumber);
            mybookings.MyBookingsSelect();
            Thread.Sleep(3000);

            //Querying DB to get BookingID which is linked with cancel button on the page.
            utilities.DBConnect("SELECT BookingID, StartTime FROM [Booking] where ReferenceNumber = '" + refnumber + "'");
            Thread.Sleep(2000);
            string S1 = utilities.data[0];
            string S2 = utilities.data[1];

            Console.WriteLine("Test: " + S1);
            Console.WriteLine("Booking Date : " + S2);

            DateTime Date  = Convert.ToDateTime(S2);
            string   date  = Date.ToShortDateString();
            int      month = Date.Month;

            Console.WriteLine(date);
            Console.WriteLine(month);

            DateTime TodayDate  = DateTime.Now;
            int      TodayMonth = TodayDate.Month;

            Console.WriteLine("Current Month : " + TodayMonth);


            //Passing Text inside Text Box with JavascriptExecutor
            IWebElement         element = driver.FindElement(By.CssSelector(".mybooking-calendar .text-box"));
            IJavaScriptExecutor jse     = (IJavaScriptExecutor)driver;

            jse.ExecuteScript("arguments[0].value='" + S2 + "';", element);

            driver.FindElement(By.CssSelector(".mybooking-calendar .text-box")).SendKeys(Keys.Enter);

            Thread.Sleep(2000);

            this.driver.FindElement(By.XPath("//*[@id='page-wrap']/section[3]/span[1]")).Click();


            //Try and catch block. When try element is not found. No such element expection is thrown and then changing the page number and going through the whole processs again.
            try
            {
                IJavaScriptExecutor ex1 = (IJavaScriptExecutor)driver;
                ex1.ExecuteScript("arguments[0].click();", driver.FindElement(By.XPath("//*[@data-id='" + S1 + "']")));
            }
            catch (NoSuchElementException e)
            {
                IList <IWebElement>       se         = driver.FindElements(By.XPath("//*[@id='customPageList']/div/ul/li"));
                IEnumerator <IWebElement> enumerator = se.GetEnumerator();

                bool hasNext = enumerator.MoveNext();

                while (hasNext)
                {
                    login.Wait();

                    int c = se.Count;

                    this.driver.FindElement(By.XPath("//*[@id='customPageList']/div/ul/li[" + c + "]/a")).Click();

                    Thread.Sleep(2000);

                    try
                    {
                        IJavaScriptExecutor ex1 = (IJavaScriptExecutor)driver;
                        ex1.ExecuteScript("arguments[0].click();", driver.FindElement(By.XPath("//*[@data-id='" + S1 + "']")));

                        var abc = this.driver.FindElement(By.XPath("//*[@id='ConfirmationModal']/div"));

                        if (abc.Displayed)
                        {
                            break;
                        }
                    }
                    catch (NoSuchElementException e2)
                    {
                        hasNext = enumerator.MoveNext();
                    }
                }
                enumerator.Dispose();
            }

            var confirmText = this.driver.FindElement(By.XPath("//*[@id='ConfirmationModal']/div[1]"));

            var CancelText = this.driver.FindElement(By.XPath("//*[@id='myBookingdialog']/div[1]"));

            //If Confirmation box contains the ref number then click on yes. If cancel text contains Ref number then click on OK.
            if (confirmText.Text.Contains(refnumber))
            {
                mybookings.YesBTN();

                if (CancelText.Text.Contains("Booking with reference number " + refnumber + " cancelled successfully"))
                {
                    mybookings.SelectOK();
                    Console.WriteLine("Booking Cancelled Successfully");
                    utilities.extenttest.Log(LogStatus.Pass, "Assert pass ");
                }
            }
            //If
            else
            {
                Console.WriteLine("Reference numnber doesn't match");
                Assert.Fail();
            }
        }
コード例 #5
0
        public void ChangeResource()
        {
            utilities.ConsoleMessageStart();

            utilities.extenttest = utilities.extent.StartTest("ChangeResource");
            //  utilities.extenttest = utilities.extent.StartTest("Find Resource");

            login.NavigateTo();
            login.LoginSuccess();
            login.Wait();
            Thread.Sleep(4000);
            homepage.SelectResource();
            Thread.Sleep(2000);
            homepage.NextButton();
            login.Wait();
            Thread.Sleep(2500);
            bookings.BookingTitle();
            //homepage.NextButton();
            login.Wait();
            Thread.Sleep(4000);
            editbooking.CloseButton();
            Thread.Sleep(3000);
            mybooking.MyBookingsEnter();
            login.Wait();
            Thread.Sleep(5000);
            editbooking.EditBookingPencil();
            login.Wait();
            Thread.Sleep(4000);
            editbooking.EditBookingBurgerButton();
            Thread.Sleep(4000);
            editbooking.EditResourceDropdownSelectChangeResource();
            login.Wait();
            Thread.Sleep(4500);
            editbooking.ChangeResourceBTN();
            Thread.Sleep(4000);
            editbooking.Finding();
            Thread.Sleep(6000);
            editbooking.ExactMatchSelect();
            Thread.Sleep(3000);
            homepage.NextButton();
            Thread.Sleep(4000);
            //editbooking.Next();
            // homepage.NextButton();
            Thread.Sleep(4000);
            login.Wait();
            //editbooking.Finish();
            editbooking.FinishBTN();
            //EditBooking.CloseButton();
            // homepage.NextButton();

            // editbooking.EditBookingResource();

            /* Assert.IsTrue(driver.FindElement(By.XPath("//*[@id='tblResourcesGrid']/tbody/tr[2]/td")).Displayed);
             * utilities.extenttest.Log(LogStatus.Pass, "Assert pass ");
             * utilities.extenttest.Log(LogStatus.Info, "Test");*/
        }