public void WhenIClickedOnTheCmenuOfCourse()
 {
     try
     {
         _wSEnrollmentpage.ClickCourseCmenu();
     }
     catch (Exception e)
     {
         GenericHelper.Logs(e.ToString(), "FAILED");
         if (Browser.Equals("FF") || Browser.Equals("IE"))
         {
             BackedSelenium.SelectWindow("");
         }
         if (Browser.Equals("GC"))
         {
             GenericHelper.SelectDefaultWindow();
         }
         IWebElement clickLogoutLink = WebDriver.FindElement((By.XPath(LogOut)));
         if (clickLogoutLink.Displayed && clickLogoutLink.Enabled)
         {
             WebDriver.SwitchTo().DefaultContent();
             new Actions(WebDriver).Click(clickLogoutLink).Perform();
         }
         Thread.Sleep(7000);
         throw new Exception(e.ToString());
     }
 }
Beispiel #2
0
        public void ThenItShouldDisplayAlertForNewGrades()
        {
            try
            {
                _todaysViewPage.VerifyNewGradesAlert();
            }
            catch (Exception e)
            {
                GenericHelper.Logs(e.ToString(), "FAILED");
                if (Browser.Equals("FF") || Browser.Equals("IE"))
                {
                    BackedSelenium.SelectWindow("");
                }
                if (Browser.Equals("GC"))
                {
                    GenericHelper.SelectDefaultWindow();
                }

                IWebElement clickLogoutLink = WebDriver.FindElement((By.XPath(LogOut)));
                if (clickLogoutLink.Displayed && clickLogoutLink.Enabled)
                {
                    WebDriver.SwitchTo().DefaultContent();
                    new Actions(WebDriver).Click(clickLogoutLink).Perform();
                }
                Thread.Sleep(7000);
                throw new Exception(e.ToString());
            }
        }
 public void WhenCreateCourseWithDetails(Table table)
 {
     try
     {
         foreach (var tableRow in table.Rows)
         {
             GenericDefinitions.WhenIClickedOnTheCreateNewLink("Create New Courses", "right");
             Thread.Sleep(2000);
             _newCoursPage.CreateCourse(tableRow["Value"]);
         }
     }
     catch (Exception e)
     {
         GenericHelper.Logs(e.ToString(), "FAILED");
         if (Browser.Equals("FF") || Browser.Equals("IE"))
         {
             BackedSelenium.SelectWindow("");
         }
         if (Browser.Equals("GC"))
         {
             GenericHelper.SelectDefaultWindow();
         }
         IWebElement clickLogoutLink = WebDriver.FindElement((By.XPath(LogOut)));
         if (clickLogoutLink.Displayed && clickLogoutLink.Enabled)
         {
             WebDriver.SwitchTo().DefaultContent();
             new Actions(WebDriver).Click(clickLogoutLink).Perform();
         }
         Thread.Sleep(7000);
         throw new Exception(e.ToString());
     }
 }
Beispiel #4
0
        public void SetThePreferencesForCustomContent()
        {
            try
            {
                _objCustom.ToSelectCustomContentSubTab();
            }
            catch (Exception e)
            {
                GenericHelper.Logs(e.ToString(), "Failed");
                if (Browser.Equals("FF") || Browser.Equals("IE"))
                {
                    BackedSelenium.SelectWindow("");
                }
                if (Browser.Equals("GC"))
                {
                    GenericHelper.SelectDefaultWindow();
                }

                IWebElement clickLogoutLink = WebDriver.FindElement((By.XPath(LogOut)));
                if (clickLogoutLink.Displayed && clickLogoutLink.Enabled)
                {
                    WebDriver.SwitchTo().DefaultContent();
                    new Actions(WebDriver).Click(clickLogoutLink).Perform();
                }
                Thread.Sleep(7000);
                throw new Exception(e.ToString());
            }
        }
        public void WhenImovetotheCalendar()
        {
            try
            {
                GenericHelper.SelectWindow("Content");
                GenericHelper.WaitUntilElement(By.PartialLinkText("Calendar"));
                WebDriver.FindElement(By.PartialLinkText("Calendar")).Click();
            }
            catch (Exception e)
            {
                GenericHelper.Logs(e.ToString(), "FAILED");
                if (Browser.Equals("FF") || Browser.Equals("IE"))
                {
                    BackedSelenium.SelectWindow("");
                }
                if (Browser.Equals("GC"))
                {
                    GenericHelper.SelectDefaultWindow();
                }

                IWebElement clickLogoutLink = WebDriver.FindElement((By.XPath(LogOut)));
                if (clickLogoutLink.Displayed && clickLogoutLink.Enabled)
                {
                    WebDriver.SwitchTo().DefaultContent();
                    new Actions(WebDriver).Click(clickLogoutLink).Perform();
                }
                Thread.Sleep(7000);
                throw new Exception(e.ToString());
            }
        }
        public void WhenISelectTheWsUser()
        {
            try
            {
                string username = DatabaseTools.GetUsername(Enumerations.UserType.WsTeacher);
                _wSEnrollmentpage.SelectUser(username);
            }
            catch (Exception e)
            {
                GenericHelper.Logs(e.ToString(), "FAILED");
                if (Browser.Equals("FF") || Browser.Equals("IE"))
                {
                    BackedSelenium.SelectWindow("");
                }
                if (Browser.Equals("GC"))
                {
                    GenericHelper.SelectDefaultWindow();
                }

                IWebElement clickLogoutLink = WebDriver.FindElement((By.XPath(LogOut)));
                if (clickLogoutLink.Displayed && clickLogoutLink.Enabled)
                {
                    WebDriver.SwitchTo().DefaultContent();
                    new Actions(WebDriver).Click(clickLogoutLink).Perform();
                }
                Thread.Sleep(7000);
                throw new Exception(e.ToString());
            }
        }
        public void ThenIShouldSeeTheEnrolledTeacherShouldPresentInRightFrameAsARoleNameAsTeacher()
        {
            try
            {
                _wSEnrollmentpage.VerifyEnrolledUser();
            }
            catch (Exception e)
            {
                GenericHelper.Logs(e.ToString(), "FAILED");
                if (Browser.Equals("FF") || Browser.Equals("IE"))
                {
                    BackedSelenium.SelectWindow("");
                }
                if (Browser.Equals("GC"))
                {
                    GenericHelper.SelectDefaultWindow();
                }

                IWebElement clickLogoutLink = WebDriver.FindElement((By.XPath(LogOut)));
                if (clickLogoutLink.Displayed && clickLogoutLink.Enabled)
                {
                    WebDriver.SwitchTo().DefaultContent();
                    new Actions(WebDriver).Click(clickLogoutLink).Perform();
                }
                Thread.Sleep(7000);
                throw new Exception(e.ToString());
            }
        }
        public void WhenIDragAndDropTheActivityToTheCalendar()
        {
            try
            {
                _objCal.ToDragAndDrop();
            }
            catch (Exception e)
            {
                GenericHelper.Logs(e.ToString(), "FAILED");
                if (Browser.Equals("FF") || Browser.Equals("IE"))
                {
                    BackedSelenium.SelectWindow("");
                }
                if (Browser.Equals("GC"))
                {
                    GenericHelper.SelectDefaultWindow();
                }

                IWebElement clickLogoutLink = WebDriver.FindElement((By.XPath(LogOut)));
                if (clickLogoutLink.Displayed && clickLogoutLink.Enabled)
                {
                    WebDriver.SwitchTo().DefaultContent();
                    new Actions(WebDriver).Click(clickLogoutLink).Perform();
                }
                Thread.Sleep(7000);
                throw new Exception(e.ToString());
            }
        }
        public void ThenIWaitForTheCourseOutFromAssignToCopyState()
        {
            try
            {
                WebDriver.SwitchTo().Window("");
                _wSEnrollmentpage.CourseSearch(_mlName);
                _wSEnrollmentpage.CheckAssignedToCopyState(_mlName);
            }
            catch (Exception e)
            {
                GenericHelper.Logs(e.ToString(), "FAILED");
                if (Browser.Equals("FF") || Browser.Equals("IE"))
                {
                    BackedSelenium.SelectWindow("");
                }
                if (Browser.Equals("GC"))
                {
                    GenericHelper.SelectDefaultWindow();
                }

                IWebElement clickLogoutLink = WebDriver.FindElement((By.XPath(LogOut)));
                if (clickLogoutLink.Displayed && clickLogoutLink.Enabled)
                {
                    WebDriver.SwitchTo().DefaultContent();
                    new Actions(WebDriver).Click(clickLogoutLink).Perform();
                }
                Thread.Sleep(7000);
                throw new Exception(e.ToString());
            }
        }
Beispiel #10
0
        //Purpose: Method To Wait For a particular Element on The Page Through Backed Selenium
        public static void WaitForElement(string elementValue)
        {
            Boolean elementFound = false;
            var     sw           = new Stopwatch();

            sw.Start();
            int secondsToWait = Int32.Parse(ConfigurationManager.AppSettings["WaitUntillElementSeconds"]);

            while (sw.Elapsed.TotalSeconds < secondsToWait)
            {
                if (BackedSelenium.IsElementPresent(elementValue))
                {
                    elementFound = true;
                    break;
                }
            }
            if (!elementFound)
            {
                Logs(
                    String.Format(
                        "The expected element '{0}' has not found under specified time interval of '{1}' second(s).",
                        elementValue, secondsToWait), "FAILED");
                throw new TimeoutException(
                          String.Format(
                              "The expected element '{0}' has not found under specified time interval of '{1}' second(s).",
                              elementValue, secondsToWait));
            }
            sw.Stop();
            sw = null;
        }
 public static void ThenItShouldDisplaySuccessfulMessage(string successMsg)
 {
     try
     {
         if (Browser.Equals("FF") || Browser.Equals("IE"))
         {
             BackedSelenium.SelectWindow("");
         }
         if (Browser.Equals("GC"))
         {
             GenericHelper.SelectDefaultWindow();
         }
         bool ismessagedisplayed = GenericHelper.VerifySuccesfullMessage(successMsg);
         if (ismessagedisplayed == true)
         {
             GenericHelper.Logs(successMsg + " :successful message displayed.", "PASSED");
         }
         else
         {
             GenericHelper.Logs(successMsg + " :successful message not displayed.", "FAILED");
             Assert.Fail(successMsg + " :successful message not displayed.");
         }
     }
     catch (Exception e)
     {
         GenericHelper.Logs(e.ToString(), "FAILED");
         throw new Exception(e.ToString());
     }
 }
 public static void ThenIShouldSeeTheNewPopup(string pageName)
 {
     try
     {
         string popupName = null;
         GenericHelper.WaitUtilWindow(pageName);
         popupName = WebDriver.WindowHandles.Last();
         if (popupName == pageName)
         {
             GenericHelper.Logs(pageName + " popup is displayed.", "PASSED");
         }
         else if (popupName != pageName)
         {
             popupName = WebDriver.WindowHandles.First();
             if (popupName == pageName)
             {
                 GenericHelper.Logs(pageName + " popup is displayed.", "PASSED");
             }
         }
         else
         {
             GenericHelper.Logs(pageName + " popup is not displayed.", "FAILED");
             throw new NoSuchWindowException(pageName + " popup is not displayed.");
         }
     }
     catch (Exception e)
     {
         if (Browser.Equals("FF") || Browser.Equals("IE"))
         {
             BackedSelenium.SelectWindow("");
         }
         if (Browser.Equals("GC"))
         {
             GenericHelper.SelectDefaultWindow();
         }
         IWebElement clickLogoutLink = WebDriver.FindElement((By.XPath(LogOut)));
         if (clickLogoutLink.Displayed && clickLogoutLink.Enabled)
         {
             WebDriver.SwitchTo().DefaultContent();
             new Actions(WebDriver).Click(clickLogoutLink).Perform();
         }
         Thread.Sleep(7000);
         GenericHelper.Logs(e.ToString(), "FAILED");
         throw new Exception(e.ToString());
     }
 }
 public static void ThenIClickedOnTheLogoutLinkToGetLoggedOutFromTheApplication()
 {
     try
     {
         if (Browser.Equals("FF") || Browser.Equals("IE"))
         {
             BackedSelenium.SelectWindow("");
         }
         if (Browser.Equals("GC"))
         {
             GenericHelper.SelectDefaultWindow();
         }
         WebDriver.SwitchTo().DefaultContent();
         GenericHelper.WaitUntilElement((By.XPath(LogOut)));
         IWebElement clickLogoutLink = WebDriver.FindElement((By.XPath(LogOut)));
         if (clickLogoutLink.Displayed && clickLogoutLink.Enabled)
         {
             clickLogoutLink.Click();
         }
         bool logout = WebDriver.Url.Contains("logout") || WebDriver.Url.Contains("frmLogOut");
         if (logout)
         {
             GenericHelper.Logs("Logout from the application successfull.", "PASSED");
         }
         else
         {
             if (!logout)
             {
                 clickLogoutLink.Click();
             }
             else
             {
                 GenericHelper.Logs("Logout from the application unsuccessfull.", "FAILED");
                 Assert.Fail("Logout from the application unsuccessfull.");
             }
         }
     }
     catch (Exception e)
     {
         GenericHelper.Logs(e.ToString(), "FAILED");
         throw new Exception(e.ToString());
     }
 }
Beispiel #14
0
        public void ThenItShouldDisplayTheNameOfSubmittedActivity()
        {
            GenericHelper.SelectWindow("Overview");
            try
            {
                if (GenericHelper.IsElementPresent(By.Id("TodayInsNewGradeDatagrid")))
                {
                    if (WebDriver.FindElement(By.Id("TodayInsNewGradeDatagrid")).Text.Contains("There are no items."))
                    {
                        GenericHelper.Logs("New Alert for Activity is not dispalyed on clicking 'New Grades' Alert", "FAILED");
                        throw new Exception("New Alert for Activity is not dispalyed on clicking 'New Grades' Alert");
                    }
                    else
                    {
                        GenericHelper.Logs("New Alert for Activity is dispalyed on clicking 'New Grades' Alert", "PASSED");
                    }
                }
            }
            catch (Exception e)
            {
                GenericHelper.Logs(e.ToString(), "FAILED");
                if (Browser.Equals("FF") || Browser.Equals("IE"))
                {
                    BackedSelenium.SelectWindow("");
                }
                if (Browser.Equals("GC"))
                {
                    GenericHelper.SelectDefaultWindow();
                }

                IWebElement clickLogoutLink = WebDriver.FindElement((By.XPath(LogOut)));
                if (clickLogoutLink.Displayed && clickLogoutLink.Enabled)
                {
                    WebDriver.SwitchTo().DefaultContent();
                    new Actions(WebDriver).Click(clickLogoutLink).Perform();
                }
                Thread.Sleep(7000);
                throw new Exception(e.ToString());
            }
            WebDriver.SwitchTo().DefaultContent();
            GenericHelper.SelectWindow("Overview");
        }
Beispiel #15
0
        public void WhenICreateTheUserWithUserDetails(Table table)
        {
            try
            {
                // Purpose: Username and Password will be written to DB
                string username = string.Empty;
                switch (((string[])(table.Rows[0].Values))[1])
                {
                case "Teacher":
                    username = GenericHelper.GenerateUniqueVariable("Teach");
                    break;

                case "Student":
                    username = GenericHelper.GenerateUniqueVariable("Stud");
                    break;
                }
                _newUserPage.AddNewUser(table, username);
            }
            catch (Exception e)
            {
                GenericHelper.Logs(e.ToString(), "FAILED");
                if (Browser.Equals("FF") || Browser.Equals("IE"))
                {
                    BackedSelenium.SelectWindow("");
                }
                if (Browser.Equals("GC"))
                {
                    GenericHelper.SelectDefaultWindow();
                }

                IWebElement clickLogoutLink = WebDriver.FindElement((By.XPath(LogOut)));
                if (clickLogoutLink.Displayed && clickLogoutLink.Enabled)
                {
                    WebDriver.SwitchTo().DefaultContent();
                    new Actions(WebDriver).Click(clickLogoutLink).Perform();
                }
                Thread.Sleep(7000);
                throw new Exception(e.ToString());
            }
        }
        public void GivenIAmOnTheUserEnrollmentPage()
        {
            try
            {
                string browserName = WebDriver.Title;
                if (browserName == "Course Enrollment")
                {
                    GenericHelper.Logs("WS Course Enrollment Page is dispalyed", "PASSED");
                }
                else
                {
                    GenericHelper.Logs("WS Course Enrollment Page is not dispalyed", "FAILED");
                }
            }
            catch (Exception e)
            {
                GenericHelper.Logs(e.ToString(), "FAILED");
                if (Browser.Equals("FF") || Browser.Equals("IE"))
                {
                    BackedSelenium.SelectWindow("");
                }
                if (Browser.Equals("GC"))
                {
                    GenericHelper.SelectDefaultWindow();
                }

                IWebElement clickLogoutLink = WebDriver.FindElement((By.XPath(LogOut)));
                if (clickLogoutLink.Displayed && clickLogoutLink.Enabled)
                {
                    WebDriver.SwitchTo().DefaultContent();
                    new Actions(WebDriver).Click(clickLogoutLink).Perform();
                }
                Thread.Sleep(7000);
                throw new Exception(e.ToString());
            }
        }