//purpose - to search for assigned to copy class
 public void ToSearchForAssigned(Enumerations.ClassType classtype)
 {
     try
     {
         GenericHelper.SelectWindow("Manage Organization");
         WebDriver.SwitchTo().Frame("frm");
         GenericHelper.WaitUntilElement(By.Id("spnSearch"));
         WebDriver.FindElement(By.Id("spnSearch")).Click();
         string className = DatabaseTools.GetClass(classtype);
         GenericHelper.WaitUntilElement(By.Id("txtSectionDetail"));
         WebDriver.FindElement(By.Id("txtSectionDetail")).Clear();
         WebDriver.FindElement(By.Id("txtSectionDetail")).SendKeys(className);
         GenericHelper.WaitUntilElement(By.Id("SearchSections"));
         IWebElement searchSection = WebDriver.FindElement(By.Id("SearchSections"));
         new Actions(WebDriver).Click(searchSection).Perform();
         // Purpose: Method To Verify Assigned to Copy State
         GenericHelper.SelectWindow("Manage Organization");
         WebDriver.SwitchTo().Frame("frm");
         GenericHelper.WaitUntilElement(By.Id("grdClasses$divContent"));
         #region Browser Selection
         if (Browser.Equals("FF") || Browser.Equals("GC"))
         {
             if (WebDriver.FindElement(By.Id("grdClasses$divContent")).Text.Contains(className))
             {
                 GenericHelper.Logs(string.Format("Class '{0}' found in the grid after searching it from the search option.", className), "PASSED");
             }
             else
             {
                 GenericHelper.Logs(string.Format("Class '{0}' not found in the grid after searching it from the search option.", className), "FAILED");
                 throw new NoSuchElementException(string.Format("Class '{0}' not found in the grid after searching it from the search option.", className));
             }
         }
         if (Browser.Equals("IE"))
         {
             if (WebDriver.FindElement(By.Id("grdClasses$divContent")).GetAttribute("innerText").Contains(className))
             {
                 GenericHelper.Logs(string.Format("Class '{0}' found in the grid after searching it from the search option.", className), "PASSED");
             }
             else
             {
                 GenericHelper.Logs(string.Format("Class '{0}' not found in the grid after searching it from the search option.", className), "FAILED");
                 throw new NoSuchElementException(string.Format("Class '{0}' not found in the grid after searching it from the search option.", className));
             }
         }
         #endregion Browser Selection
         Stopwatch sw = new Stopwatch();
         sw.Start();
         int minutesToWait = Int32.Parse(ConfigurationManager.AppSettings["AssignedToCopyInterval"]);
         while (sw.Elapsed.Minutes < minutesToWait)
         {
             IWebElement redTextPresent = WebDriver.FindElement(By.TagName("body"));
             if (redTextPresent.Text.Contains("[Assigned to copy]") == false)
             {
                 break;
             }
             {
                 GenericHelper.SelectWindow("Manage Organization");
                 WebDriver.SwitchTo().Frame("frm");
                 GenericHelper.WaitUntilElement(By.Id("spnSearch"));
                 WebDriver.FindElement(By.Id("spnSearch")).Click();
                 Thread.Sleep(5000);// This I added to load the search panel
                 GenericHelper.WaitUntilElement(By.Id("txtSectionDetail"));
                 WebDriver.FindElement(By.Id("txtSectionDetail")).Clear();
                 WebDriver.FindElement(By.Id("txtSectionDetail")).SendKeys(className);
                 GenericHelper.WaitUntilElement(By.Id("SearchSections"));
                 IWebElement searchClass = WebDriver.FindElement(By.Id("SearchSections"));
                 new Actions(WebDriver).Click(searchClass).Perform();
                 Thread.Sleep(10000);
                 GenericHelper.SelectWindow("Manage Organization");
                 WebDriver.SwitchTo().Frame("frm");
             }
         }
         if (GenericHelper.IsElementPresent(By.XPath(Text_AssignedToCopy)))
         {
             GenericHelper.Logs(string.Format("[AssignedToCopy] state has not validated under:'{0}' minutes for copying '{1}'.", minutesToWait, className), "FAILED");
         }
         else
         {
             GenericHelper.Logs(string.Format("[AssignedToCopy] state has validated under:'{0}' minutes for copying '{1}'.", minutesToWait, className), "PASSED");
         }
         sw.Stop();
         sw = null;
     }
     catch (Exception e)
     {
         GenericHelper.Logs(e.ToString(), "FAILED");
         if (GenericHelper.IsPopUpWindowPresent("Manage Organization"))
         {
             GenericHelper.SelectWindow("Manage Organization");
             WebDriver.Close();
         }
         throw new Exception(e.ToString());
     }
 }
 //Purpose : To select the class in Enrollment tab of Manage Organization Page
 public void SelectClass(Enumerations.ClassType classType)
 {
     try
     {
         string classname = DatabaseTools.GetClass(classType);
         GenericHelper.SelectWindow("Manage Organization");
         GenericHelper.WaitUntilElement(By.Id("frm"));
         WebDriver.SwitchTo().Frame("frm");
         WebDriver.SwitchTo().DefaultContent();
         GenericHelper.WaitUntilElement(By.Id("frm"));
         WebDriver.SwitchTo().Frame("frm");
         WebDriver.SwitchTo().Frame("ifrmright");
         GenericHelper.WaitUntilElement(By.Id("spnSearch"));
         WebDriver.FindElement(By.Id("spnSearch")).Click();
         GenericHelper.WaitUntilElement(By.Id("txtSectionDetail"));
         WebDriver.FindElement(By.Id("txtSectionDetail")).SendKeys(classname);
         GenericHelper.WaitUntilElement(By.Id("btnSearch"));
         WebDriver.FindElement(By.Id("btnSearch")).Click();
         try
         {
             bool isEnrollTablePresent = GenericHelper.IsElementPresent(By.Id("MainTable"));
             if (isEnrollTablePresent)
             {
                 string noRecordMessagePresent = WebDriver.FindElement(By.Id("MainTable")).Text;
                 if (noRecordMessagePresent.Contains("There are no classes or courses available to you."))
                 {
                     GenericHelper.Logs("There are no classes or courses available to you.", "FAILED");
                     throw new NoSuchElementException("There are no classes or courses available to you.");
                 }
             }
         }
         catch (Exception e)
         {
             GenericHelper.Logs(e.ToString(), "FAILED");
             throw new Exception(e.ToString());
         }
         GenericHelper.WaitUntilElement(By.XPath("//table[@class='CourseLabelHeight']/tbody/tr/td/span"));
         #region Browser Selection
         if (Browser.Equals("FF") || Browser.Equals("GC"))
         {
             if (classname.StartsWith(WebDriver.FindElement(By.XPath("//table[@class='CourseLabelHeight']/tbody/tr/td/span")).Text.TrimEnd('.')))
             {
                 GenericHelper.WaitUntilElement(By.XPath(ImageExpand));
                 WebDriver.FindElement(By.XPath(ImageExpand)).Click();
                 GenericHelper.WaitUntilElement(By.CssSelector("input[id$='allcourse']"));
                 WebDriver.FindElement(By.CssSelector("input[id$='allcourse']")).Click();
                 GenericHelper.Logs("Searched class " + classname + " found", "PASSED");
             }
             else
             {
                 GenericHelper.Logs("Searched class " + classname + " not found", "FAILED");
             }
         }
         if (Browser.Equals("IE"))
         {
             if (classname.StartsWith(WebDriver.FindElement(By.XPath("//table[@class='CourseLabelHeight']/tbody/tr/td/span")).Text.TrimEnd('.')))
             {
                 GenericHelper.WaitUntilElement(By.Id("grdEnrollmentClasses__ctl0_expandImgDiv"));
                 WebDriver.FindElement(By.Id("grdEnrollmentClasses__ctl0_expandImgDiv")).Click();
                 GenericHelper.WaitUntilElement(By.CssSelector("input[id$='allcourse']"));
                 WebDriver.FindElement(By.CssSelector("input[id$='allcourse']")).Click();
                 GenericHelper.Logs("Searched class " + classname + " found", "PASSED");
             }
             else
             {
                 GenericHelper.Logs("Searched class " + classname + " not found", "FAILED");
             }
         }
         #endregion Browser Selection
     }
     catch (Exception e)
     {
         GenericHelper.Logs(e.ToString(), "FAILED");
         if (GenericHelper.IsPopUpWindowPresent("Manage Organization"))
         {
             GenericHelper.SelectWindow("Manage Organization");
             WebDriver.Close();
         }
         throw new Exception(e.ToString());
     }
 }
示例#3
0
        //purpose - to search for assigned to copy class
        public void ToSearchForAssigned(Enumerations.ClassType classtype)
        {
            GenericHelper.SelectWindow("Manage Organization");
            GenericHelper.WaitUntilElement(By.Id("frm"));
            WebDriver.SwitchTo().Frame("frm");
            GenericHelper.WaitUntilElement(By.Id("spnSearch"));
            WebDriver.FindElement(By.Id("spnSearch")).Click();
            WebDriver.SwitchTo().ActiveElement();
            string className = DatabaseTools.GetClass(classtype);

            GenericHelper.WaitUntilElement(By.Id("txtSectionDetail"));
            WebDriver.FindElement(By.Id("txtSectionDetail")).Clear();
            WebDriver.FindElement(By.Id("txtSectionDetail")).SendKeys(className);
            WebDriver.FindElement(By.Id("SearchSections")).Click();
            Thread.Sleep(3000);
            // Purpose: Method To Verify Assigned to Copy State
            GenericHelper.SelectWindow("Manage Organization");
            WebDriver.SwitchTo().Frame("frm");
            GenericHelper.WaitUntilElement(By.Id("grdClasses$divContent"));
            Stopwatch sw = new Stopwatch();

            sw.Start();
            int minutesToWait = Int32.Parse(ConfigurationManager.AppSettings["AssignedToCopyInterval"]);

            while (sw.Elapsed.Minutes < minutesToWait)
            {
                IWebElement redTextPresent = WebDriver.FindElement(By.TagName("body"));
                if (redTextPresent.Text.Contains("[Assigned to copy]"))
                {
                    GenericHelper.SelectWindow("Manage Organization");
                    GenericHelper.WaitUntilElement(By.Id("frm"));
                    WebDriver.SwitchTo().Frame("frm");
                    Thread.Sleep(20000);
                    GenericHelper.WaitUntilElement(By.Id("spnSearch"));
                    WebDriver.FindElement(By.Id("spnSearch")).Click();
                    Thread.Sleep(3000);
                    WebDriver.SwitchTo().ActiveElement();
                    GenericHelper.WaitUntilElement(By.Id("txtSectionDetail"));
                    WebDriver.FindElement(By.Id("txtSectionDetail")).Clear();
                    WebDriver.FindElement(By.Id("txtSectionDetail")).SendKeys(className);
                    WebDriver.FindElement(By.Id("SearchSections")).Click();
                    Thread.Sleep(3000);
                    WebDriver.SwitchTo().ActiveElement();
                    GenericHelper.SelectWindow("Manage Organization");
                    WebDriver.SwitchTo().Frame("frm");
                    GenericHelper.WaitUntilElement(By.Id("grdClasses$divContent"));
                    #region Browser Selection
                    if (Browser.Equals("FF"))
                    {
                        if (WebDriver.FindElement(By.Id("grdClasses$divContent")).Text.Contains(className))
                        {
                            GenericHelper.Logs("Class found in the grid after searching it from the search option", "PASSED");
                        }
                        else
                        {
                            GenericHelper.Logs("Class not found in the grid after searching it from the search option", "FAILED");
                        }
                    }
                    if (Browser.Equals("IE"))
                    {
                        if (WebDriver.FindElement(By.Id("grdClasses$divContent")).GetAttribute("innerText").Contains(className))
                        {
                            GenericHelper.Logs("Class found in the grid after searching it from the search option", "PASSED");
                        }
                        else
                        {
                            GenericHelper.Logs("Class not found in the grid after searching it from the search option", "FAILED");
                        }
                    }
                    #endregion Browser Selection
                }
                else
                {
                    break;
                }
            }
            try
            {
                IWebElement redTextPresent = WebDriver.FindElement(By.TagName("body"));
                if (redTextPresent.Text.Contains("[Assigned to copy]"))
                {
                    GenericHelper.Logs(string.Format("[AssignedToCopy] state has not validated under:'{0}' minutes for copying '{1}'.", minutesToWait, className), "FAILED");
                }
                else
                {
                    GenericHelper.Logs(string.Format("[AssignedToCopy] state has validated under:'{0}' minutes for copying '{1}'.", minutesToWait, className), "PASSED");
                }
            }
            catch (Exception e)
            {
                GenericHelper.Logs(e.Message, "FAILED");
            }
            sw.Stop();
            sw = null;
        }