/// <summary>
        /// ClickCreateNewAccount method click on create new account button
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="reporter"></param>
        public static void ClickCreateNewAccount(RemoteWebDriver driver, Iteration reporter)
        {
            reporter.Add(new Act("Click on Create New Account button"));
            Selenide.Click(driver, Util.GetLocator("createaccount_btn"));

            // *** Create New account redirects to AccountRegister Page *** //
        }
 /// <summary>
 /// CloseStoreLocatorPopupWindow clicks on close icon of doctors entry popup
 /// </summary>
 /// <param name="Driver">Initialized RemoteWebDriver instance</param>
 /// <param name="reporter"></param>
 public static void CloseStoreLocatorPopupWindow(RemoteWebDriver driver, Iteration reporter, string resultsPath)
 {
     try
     {
         reporter.Add(new Act("Close Store Locator Popup Window"));
         //Selenide.SwitchToDefaultContent(driver);
         //Selenide.SwitchToFrame(driver, Locator.Get(LocatorType.ID, "dlg_ifrm_search"));
         Selenide.WaitForElementNotVisible(driver, Locator.Get(LocatorType.ClassName, "dlg_spinner"));
         if (Selenide.IsElementExists(driver, Locator.Get(LocatorType.ID, "createmsgdiv")))
         {
             CommonPage.AcceptErrorMessageIfPresent(driver, reporter, resultsPath);
         }
         //if (Selenide.IsElementExists(driver, Util.GetLocator("Cancel_btn")))
         //{
         //    Selenide.Click(driver, Util.GetLocator("Cancel_btn"));
         //}
         if (Selenide.IsElementExists(driver, Util.GetLocator("StoreInfoCloseBtn_win")))
         {
             Selenide.Click(driver, Util.GetLocator("StoreInfoCloseBtn_win"));
         }
         //CommonPage.WaitUntilSpinnerDisappears(driver);
         //CommonPage.AcceptOrDissmissAlertIfPresent(driver, reporter);
         //CommonPage.AcceptErrorMessageIfPresent(driver);
         Selenide.SwitchToDefaultContent(driver);
     }
     catch (Exception ex)
     {
         CommonPage.AcceptOrDissmissAlertIfPresent(driver, reporter);
         CommonPage.AcceptErrorMessageIfPresent(driver, reporter, resultsPath);
     }
 }
Example #3
0
 public static void EnterSearchInput(RemoteWebDriver driver, string searchinput)
 {
     //Enter the search input: what is the size of the sun
     Selenide.ScrollToElement(driver, Util.GetLocator("NavigationBar"));
     Selenide.SetText(driver, Util.GetLocator("NavigationBar"), Selenide.ControlType.Textbox, searchinput);
     Selenide.Click(driver, Util.GetLocator("search_Btn"));
     test.Log(LogStatus.Pass, "Entered the search input text is 'what is the size of the sun'");
 }
 /// <summary>
 /// ClickCorporateSubLink selects sub links in Corporate
 /// </summary>
 /// <param name="driver"></param>
 /// <param name="reporter"></param>
 public static void ClickCorporateSubLink(RemoteWebDriver driver, Iteration reporter, string submenuname)
 {
     reporter.Add(new Act(String.Format("Click the {0} link under corporate sublink", submenuname)));
     Selenide.Focus(driver, Locator.Get(LocatorType.XPath,
                                        string.Format(@"//table[@class='wide100']/descendant::div[@id='bannernav']/descendant::a[text()='{0}']", submenuname)));
     Selenide.Click(driver, Locator.Get(LocatorType.XPath,
                                        string.Format(@"//table[@class='wide100']/descendant::div[@id='bannernav']/descendant::a[text()='{0}']", submenuname)));
 }
Example #5
0
 public static void ClickSigninBtn(RemoteWebDriver driver)
 {
     Selenide.BrowserBack(driver);
     //"Click Sign in from the navigation bar"
     Selenide.Wait(driver, 5, true);
     Selenide.ScrollToElement(driver, Util.GetLocator("Signin_btn"));
     Selenide.Click(driver, Util.GetLocator("Signin_btn"));
 }
Example #6
0
 public static void Logout(RemoteWebDriver driver, string username)
 {
     ////(new Act("Logoutfrom application"));
     Selenide.Wait(driver, 4, true);
     Selenide.Click(driver, Locator.Get(LocatorType.XPath, "//span[text()='" + username + "']"));
     Selenide.WaitForElementVisible(driver, Util.GetLocator("signOutLink"));
     Selenide.Click(driver, Util.GetLocator("signOutLink"));
     test.Log(LogStatus.Pass, "Log out");
 }
Example #7
0
        /// <summary>
        /// AcceptErrorMessageIfPresent method Closes errormessage if error present
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="reporter"></param>
        /// <param name="postion">Position of the link </param>
        /// <returns></returns>
        public static void AcceptErrorMessageIfPresent(RemoteWebDriver driver)
        {
            bool error = Selenide.IsElementExists(driver, Locator.Get(LocatorType.XPath, "//div[@id='createmsgdiv']/descendant::img"));

            if (error)
            {
                Selenide.Click(driver, Locator.Get(LocatorType.XPath, string.Format(@"//div[@id='createmsgdiv']/descendant::img")));
                //CommonPage.takeScreenshot(driver, screenshotName, saveTo, reporter);
            }
        }
Example #8
0
 //Select avalable date
 public static void SelectAvalabledate(RemoteWebDriver driver)
 {
     test.Log(LogStatus.Pass, "Select avalable Date");
     Selenide.Click(driver, Util.GetLocator("ScheduleTourLink"));
     Selenide.Wait(driver, 5, true);
     Selenide.Query.isElementInvisible(driver, Util.GetLocator("BooktourBtn"));
     test.Log(LogStatus.Pass, "Schedule tour window displayed");
     Common.Takescreenshot(driver);
     Selenide.Wait(driver, 5, true);
 }
Example #9
0
        /// <summary>
        /// Performs login
        /// </summary>
        /// <param name="Driver">Initialized RemoteWebDriver instance</param>
        /// <param name="username">Login Username</param>
        /// <param name="password">Login Password</param>
        public static void Login(RemoteWebDriver driver, Iteration reporter, string username, string password)
        {
            reporter.Add(new Act(String.Format("Set Username {0}, Password {1} and Click Login", username, password)));
            Selenide.WaitForElementVisible(driver, Util.GetLocator("UserNamTxtBox"));
            Selenide.SetText(driver, Util.GetLocator("UserNamTxtBox"), Selenide.ControlType.Textbox, username);
            Selenide.SetText(driver, Util.GetLocator("PasswordTxtBox"), Selenide.ControlType.Textbox, password);
            Selenide.Click(driver, Util.GetLocator("LoginBtn"));
            System.Threading.Thread.Sleep(2000);
            Actions actions = new Actions(driver);

            actions.SendKeys(OpenQA.Selenium.Keys.Escape);
            //var ajaxIsComplete = (bool)(driver as IJavaScriptExecutor).ExecuteScript("return jQuery.active == 0");
            ((IJavaScriptExecutor)driver).ExecuteScript("return window.stop();");
            var ajaxIsComplete = (bool)(driver as IJavaScriptExecutor).ExecuteScript("return jQuery.active == 0");
            //Selenide.WaitForElementVisible(driver, Util.GetLocator("DashBoardOpenTickets"));
        }
Example #10
0
        public static void LoginToWolframWithInvalidCredentials(RemoteWebDriver driver, string userName, string password)
        {
            //(new Act("Enter User name"));
            Selenide.WaitForElementVisible(driver, Util.GetLocator("User_EmailTextBox"));
            Selenide.SetText(driver, Util.GetLocator("User_EmailTextBox"), Selenide.ControlType.Textbox, userName);

            //(new Act("Enter Password"));
            Selenide.SetText(driver, Util.GetLocator("User_PasswordTextBox"), Selenide.ControlType.Textbox, password);

            //(new Act("clickon sig in button"));
            Selenide.Click(driver, Util.GetLocator("Login_SiginBtn"));

            //Verify successfully logged in to application
            Selenide.WaitForElementVisible(driver, Util.GetLocator("ErrorLogin"));
            Selenide.Query.isElementVisible(driver, Util.GetLocator("ErrorLogin"));
            test.Log(LogStatus.Pass, "Error message displayed");
        }
Example #11
0
        public static void LoginToWolfram(RemoteWebDriver driver, string userName, string password)
        {
            //(new Act("Enter User name"));
            Selenide.SetText(driver, Util.GetLocator("User_EmailTextBox"), Selenide.ControlType.Textbox, userName);

            //(new Act("Enter Password"));
            Selenide.SetText(driver, Util.GetLocator("User_PasswordTextBox"), Selenide.ControlType.Textbox, password);

            //(new Act("clickon sig in button"));
            Selenide.Click(driver, Util.GetLocator("Login_SiginBtn"));

            //Verify successfully logged in to application
            //Verify that the user name is Present in the nav bar
            Selenide.WaitForElementVisible(driver, Locator.Get(LocatorType.XPath, "//span[text()='" + userName + "']"));
            Selenide.Query.isElementVisible(driver, Locator.Get(LocatorType.XPath, "//span[text()='" + userName + "']"));
            test.Log(LogStatus.Pass, "User " + userName + "Logged in successfully");
        }
Example #12
0
        public static void ClickMetricBtn(RemoteWebDriver driver)
        {
            //Click the "Non Show Metric" button
            Selenide.Wait(driver, 5, true);
            Selenide.ScrollToElement(driver, Util.GetLocator("ShowMetricBtn"));
            Selenide.Click(driver, Util.GetLocator("ShowMetricBtn"));
            Selenide.Wait(driver, 5, true);
            //Verify that the non-metric value is not present
            //Validate in kilometers
            Selenide.Query.isElementVisible(driver, Util.GetLocator("Kilometers695700"));
            test.Log(LogStatus.Pass, "The radius of the sun is 432300 kilometers displayed");

            bool nonmetricvalue = Selenide.Query.isElementVisibleboolValue2(driver, Util.GetLocator("Radiussun432300"));

            if (!nonmetricvalue)
            {
                test.Log(LogStatus.Pass, "The metric value is not present");
            }
            else
            {
                throw new Exception("The non metric value displayed");
            }
        }
        /// <summary>
        /// ClickOnAnyStoreNumber method clicks on store number in the results
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="reporter"></param>
        /// <param name="resultsPath"></param>
        public static void ClickOnAnyStoreNumber(RemoteWebDriver driver, Iteration reporter, string resultsPath)
        {
            try
            {
                reporter.Add(new Act("Click on store number in results of Stores Directory Page"));
                //Selenide.SwitchToFrame(driver, Locator.Get(LocatorType.ID, "iFrameSiteContents"));
                if (Selenide.IsElementExists(driver, Locator.Get(LocatorType.XPath, "//table[@class='formview']/descendant::tr[2]/td//a/nobr")))
                {
                    Selenide.Click(driver, Locator.Get(LocatorType.XPath, ("//table[@class='formview']/descendant::tr[2]/td//a/nobr")));
                }
                else if (Selenide.IsElementExists(driver, Locator.Get(LocatorType.XPath, "//table[@class='formview']/descendant::tr[2]/td//a")))
                {
                    Selenide.Click(driver, Locator.Get(LocatorType.XPath, ("//table[@class='formview']/descendant::tr[2]/td//a")));
                }
                else
                {
                    reporter.Add(new Act("Results not found"));
                }

                Selenide.WaitForElementNotVisible(driver, Locator.Get(LocatorType.ClassName, "dlg_spinner"));
                //WaitForPageLoad(driver, 10);
                //CommonPage.WaitUntilSpinnerDisappears(driver);
                CommonPage.AcceptOrDissmissAlertIfPresent(driver, reporter);
                CommonPage.AcceptErrorMessageIfPresent(driver, reporter, resultsPath);
                //Selenide.SwitchToFrame(driver,Locator.Get(LocatorType.ID, "dlg_ifrm_search"));
                Selenide.SwitchToDefaultContent(driver);
            }

            catch (SystemException sysex)
            {
                //    this.Reporter.Chapter.Step.Action.Extra = sysex.Message + "<br/>" + sysex.StackTrace;
                //    Reporter.Chapter.Step.Action.IsSuccess = false;
                CommonPage.AcceptOrDissmissAlertIfPresent(driver, reporter);
                CommonPage.AcceptErrorMessageIfPresent(driver, reporter, resultsPath);
            }
        }
 /// <summary>
 /// ClickCostCenterAndVerify performs Search Operation
 /// </summary>
 /// <param name="driver"></param>
 /// <param name="reporter"></param>
 /// <param name="costcenternumber"></param>
 public static void ClickCostCenterAndVerify(RemoteWebDriver driver, Iteration reporter, string costcenternumber)
 {
     reporter.Add(new Act("Click on Search button"));
     Selenide.Click(driver, Locator.Get(LocatorType.XPath,
                                        string.Format(@"//tr[@class='GridRow_altN_selN_hovN']/td[2]/a[text()='{0}']", costcenternumber)));
 }
 /// <summary>
 /// ClickSearch performs Search Operation
 /// </summary>
 /// <param name="driver"></param>
 /// <param name="reporter"></param>
 public static void ClickSearch(RemoteWebDriver driver, Iteration reporter)
 {
     reporter.Add(new Act("Click on Search button"));
     Selenide.Click(driver, Util.GetLocator("AccountingSearch_btn"));
 }
Example #16
0
        //Click on schedule Link
        public static void ClickScheduleTourLink(RemoteWebDriver driver)
        {
            Selenide.Wait(driver, 3, true);
            test.Log(LogStatus.Pass, "Click on Schedule Tour Link");
            driver.SwitchTo().Frame(2);
            Selenide.Click(driver, Locator.Get(LocatorType.XPath, "//html/body/div/descendant::li/button[text()='Schedule a Tour']"));
            Selenide.Wait(driver, 3, true);
            driver.SwitchTo().DefaultContent();

            driver.SwitchTo().Frame(2);
            test.Log(LogStatus.Pass, "Select avalable Date");
            Selenide.Click(driver, Locator.Get(LocatorType.ID, "date"));
            Selenide.Wait(driver, 3, true);
            Selenide.Click(driver, Locator.Get(LocatorType.XPath, "(//td[@aria-disabled='false'])[1]"));
            //Selenide.JS.Click(driver, Locator.Get(LocatorType.XPath, "(//td[@aria-disabled='false'])[2]"));

            //Select time
            Selenide.Wait(driver, 3, true);
            Selenide.SetText(driver, Locator.Get(LocatorType.XPath, "//select[@tabindex='3']"), Selenide.ControlType.Index, "0");
            //Selenide.Click(driver, Locator.Get(LocatorType.XPath, "//select/option[text()='11:00 am']"));

            //Enter First Name
            Random _random = new Random();
            string uniqnum = _random.Next(0, 9999).ToString("0000");

            Selenide.SetText(driver, Locator.Get(LocatorType.XPath, "//input[@placeholder='First name']"), Selenide.ControlType.Textbox, "AutoFirst" + uniqnum);
            test.Log(LogStatus.Pass, "Entered First Name : AutoFirst" + uniqnum);

            //LastName
            Selenide.SetText(driver, Locator.Get(LocatorType.XPath, "//input[@placeholder='Last name']"), Selenide.ControlType.Textbox, "AutoLast" + uniqnum);
            test.Log(LogStatus.Pass, "Enter Last Name : AutoLast" + uniqnum);

            //Email
            Selenide.SetText(driver, Locator.Get(LocatorType.XPath, "//input[@placeholder='Email']"), Selenide.ControlType.Textbox, "AutoEmail" + uniqnum + "@gmail.com");
            test.Log(LogStatus.Pass, "Entered Email as : AutoEmail" + uniqnum + "@gmail.com");

            //Uniq Phone Number

            Random rand        = new Random(100);
            int    phoneNumber = rand.Next(0000000000, 999999999);

            //Phone Number
            Selenide.SetText(driver, Locator.Get(LocatorType.XPath, "//input[@placeholder='Phone']"), Selenide.ControlType.Textbox, "9" + phoneNumber.ToString());
            test.Log(LogStatus.Pass, "Entered Phone Number 9" + phoneNumber.ToString());

            //Message
            test.Log(LogStatus.Pass, "Enter Message");
            Selenide.SetText(driver, Locator.Get(LocatorType.XPath, "//textarea[@placeholder='Add your message']"), Selenide.ControlType.Textbox, "Hello This is Testing");

            //Bedrooms
            test.Log(LogStatus.Pass, "Select Bedrooms in dropdown");
            Selenide.Click(driver, Locator.Get(LocatorType.XPath, "//select/option[text()='2 bedroom']"));

            //Unit
            test.Log(LogStatus.Pass, "Select Unit");
            Selenide.Click(driver, Locator.Get(LocatorType.XPath, "//select/option[text()='$1312 - 1bd 1ba - Unit 321, Avail Today']"));

            //BookTour Button
            test.Log(LogStatus.Pass, "Click BookTour button");
            Selenide.Click(driver, Util.GetLocator("BooktourBtn"));

            Selenide.Wait(driver, 3, true);
            driver.SwitchTo().DefaultContent();

            Selenide.Wait(driver, 3, true);
            driver.SwitchTo().Frame(2);
            //div[@class='doorway-plugin-header doorway-themed-bg']/span
            Selenide.Wait(driver, 3, true);
            string txt = Selenide.GetText(driver, Locator.Get(LocatorType.XPath, "//div[@class='doorway-plugin-header doorway-themed-bg']//span"), Selenide.ControlType.Label);

            if (txt == "You're booked with Apartment Test 2")
            {
                test.Log(LogStatus.Pass, "Appointment Booked successfully");
                Common.Takescreenshot(driver);
            }
            else
            {
                test.Log(LogStatus.Fail, "Appointment Not Booked successfully");
                Common.Takescreenshot(driver);
            }
        }
Example #17
0
 /// <summary>
 /// Click on ok button for verification
 /// </summary>
 /// <param name="driver"></param>
 /// <param name="reporter"></param>
 public static void ClickOkButton(RemoteWebDriver driver)
 {
     //(new Act("Click on Ok button"));
     Selenide.Click(driver, Util.GetLocator("Security_ok"));
 }
Example #18
0
 /// <summary>
 /// ClickHomePageTabs method click on Home Page tabs
 /// </summary>
 /// <param name="driver"></param>
 /// <param name="reporter"></param>
 /// <param name="tabName">Tab Name where User wish to switch</param>
 public static void ClickHomePageTabs(RemoteWebDriver driver, Iteration reporter,
                                      string tabName)
 {
     reporter.Add(new Act("Click on Home Page Tab: " + tabName));
     Selenide.Click(driver, Locator.Get(LocatorType.XPath, string.Format(@"//ul/descendant::a[normalize-space()='{0}']", tabName)));
 }
        private static List <Dictionary <string, string> > DataExtractFromHuff(RemoteWebDriver driver, Iteration reporter, string sitename, List <string> urls, int k)
        {
            List <Dictionary <string, string> > data = new List <Dictionary <string, string> >();

            try
            {
                IList <IWebElement> Stories = driver.FindElementsByXPath(Util.GetLocator("StoryCount_HFP").Location);

                if (Stories.Count > 2)
                {
                    //tring to get all urls in one go
                    foreach (IWebElement story in Stories)
                    {
                        urls.Add(story.GetAttribute("href"));
                    }
                    var DistinctList = urls.Distinct();

                    reporter.Add(new Act("Got <b>" + DistinctList.Count() + "</b> Stories"));
                    foreach (string url in DistinctList)
                    {
                        if (url.StartsWith("https://www.huffingtonpost.com/entry/"))
                        {
                            Selenide.NavigateTo(driver, url);

                            Dictionary <string, string> tempdict = new Dictionary <string, string>();
                            try
                            {
                                if (driver.FindElementsById(Util.GetLocator("Story_HFP").Location).Count > 0)
                                {
                                    IList <IWebElement> StoryHeader = driver.FindElementsByXPath(Util.GetLocator("storyHeader_HFP").Location);
                                    IList <IWebElement> Story       = driver.FindElementsById(Util.GetLocator("Story_HFP").Location);
                                    string metadata = "";
                                    try
                                    {
                                        if (Selenide.Query.isElementVisibleboolValue(driver, Util.GetLocator("storyHeaderMeta_HFP"), false))
                                        {
                                            metadata = driver.FindElementByXPath(Util.GetLocator("storyHeaderMeta_HFP").Location).Text;
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                    }
                                    string totalstory = "";

                                    string storyheader = StoryHeader[0].Text;

                                    IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
                                    try
                                    {
                                        totalstory = (string)js.ExecuteScript("return document.getElementsByClassName('" + Util.GetLocator("Story_HFP_cn").Location + "')[0].innerText;");
                                        tempdict.Add(storyheader + metadata, totalstory);
                                    }
                                    catch
                                    {
                                        for (int i = 0; i < Story.Count; i++)
                                        {
                                            new Actions(driver).MoveToElement(Story[i]).Perform();
                                            Selenide.Wait(driver, 1, true);
                                            totalstory += Story[i].Text;
                                        }
                                        tempdict.Add(storyheader + metadata, totalstory);
                                    }

                                    data.Add(tempdict);
                                }
                                else
                                {
                                    reporter.Add(new Act("Current url is not working for the known scheme ::" + url));
                                }
                            }
                            catch (Exception e)
                            {
                                continue;
                            }
                        }
                    }
                }
                Selenide.NavigateTo(driver, sitename);
                if (Selenide.Query.isElementExist(driver, Locator.Get(LocatorType.XPath, "//*[@id='pagination']/div[2]//a[contains(@href,'?page=" + k + "')]"), false))
                {
                    try
                    {
                        Selenide.Click(driver, Locator.Get(LocatorType.XPath, "//*[@id='pagination']/div[2]//a[contains(@href,'?page=" + k + "')]"));
                        //driver.FindElementByXPath("//*[@id='pagination']/div[2]//a[contains(@href,'?page=2')]").Click();
                    }
                    catch (Exception e)
                    {
                        reporter.Add(new Act("Click never happened for page ::" + k));
                    }
                }
            }
            catch (Exception e)
            {
            }

            return(data);
        }
 /// <summary>
 /// Click on logout button
 /// </summary>
 /// <param name="driver"></param>
 /// <param name="reporter"></param>
 public static void clickLogout(RemoteWebDriver driver, Iteration reporter)
 {
     reporter.Add(new Act("Click on  Logout button"));
     Selenide.Click(driver, Util.GetLocator("acclogout_btn"));
 }
 /// <summary>
 /// ClickForgotPasswordLink method clicks on forgot password click here link
 /// </summary>
 /// <param name="uname">User Name </param>
 /// <param name="password">Password to login into the application</param>
 public static void ClickForgotPasswordLink(RemoteWebDriver driver, Iteration reporter)
 {
     reporter.Add(new Act("Click on forgot password link"));
     Selenide.Click(driver, Util.GetLocator("ForgotPassword_lnk"));
 }
Example #22
0
        /// <summary>
        /// ClickAllSubMenusInMenu method click the links in each menu of WebPortal
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="reporter"></param>
        /// <param name="tabName">tabName</param>
        /// <param name="resultsPath">resultsPath</param>
        ///
        public static void ClickAllSubMenusInMenu(RemoteWebDriver driver, Iteration reporter, string resultsPath, string menu)
        {
            string subMenu = string.Empty, subMenuAttribute = string.Empty;
            int    linksCountInEachMenu, linksCountInSubMenu, subMenuCount, subMenuCountInEachMenu, clickableLinksInEachMenu, linksCountInSubMenu1 = 0;

            //Clicks menu
            Selenide.Click(driver, Locator.Get(LocatorType.XPath, string.Format(@"//div[@class='menu']/ul/li/a[contains(text(),'{0}')]", menu)));

            //Number of submenu's in a menu
            //subMenuCountInEachMenu = Selenide.GetElementCount(driver, Locator.Get(LocatorType.XPath,string.Format(@"//div[@class='menu']/ul/li/a[contains(text(),'{0}')]/following-sibling::ul/li", menu)));
            subMenuCountInEachMenu = Selenide.GetElementCount(driver, Locator.Get(LocatorType.XPath, string.Format
                                                                                      (@"//div[@class='menu']/ul/li/a[normalize-space(text())='{0}']/following-sibling::ul/li", menu)));

            //Number of clickable submenu's in a menu
            linksCountInEachMenu = Selenide.GetElementCount(driver, Locator.Get(LocatorType.XPath,
                                                                                string.Format(@"//div[@class='menu']/ul/li/a[contains(text(),'{0}')]/following-sibling::ul/li/a[@onclick]", menu)));

            //Number of clickable submenu2's in a menu
            linksCountInSubMenu = Selenide.GetElementCount(driver, Locator.Get(LocatorType.XPath,
                                                                               string.Format(@"//div[@class='menu']/ul/li/a[contains(text(),'{0}')]/following-sibling::ul/li/a[@class='drop']/following-sibling::ul/li/a[@onclick]", menu)));

            //Total clickable links in a menu
            clickableLinksInEachMenu = linksCountInEachMenu + linksCountInSubMenu;

            reporter.Add(new Act(string.Format(@"Number of clickable links under <b>{0}</b> menu are: <b>{1}</b>", menu, clickableLinksInEachMenu)));

            for (subMenuCount = 1; subMenuCount <= subMenuCountInEachMenu; subMenuCount++)
            {
                subMenuAttribute = Selenide.GetElement(driver, Locator.Get(LocatorType.XPath, string.Format
                                                                               (@"//div[@class='menu']/ul/li/a[contains(text(),'{0}')]/following-sibling::ul/li[{1}]/a", menu, subMenuCount))).GetAttribute("onclick");

                if (subMenuAttribute != null)
                {
                    if (subMenuAttribute.Contains("PortalMenu") || subMenuAttribute.Contains("Schedule"))
                    {
                        subMenu = string.Empty;
                        while (subMenu == null || subMenu == string.Empty)
                        {
                            //Clicks menu
                            Selenide.Click(driver, Locator.Get(LocatorType.XPath, string.Format(@"//div[@class='menu']/ul/li/a[contains(text(),'{0}')]", menu)));

                            subMenu = Selenide.GetText(driver, Locator.Get(LocatorType.XPath,
                                                                           string.Format(@"//div[@class='menu']/ul/li/a[contains(text(),'{0}')]/following-sibling::ul/li[{1}]/a", menu, subMenuCount)),
                                                       Selenide.ControlType.Label);
                        }
                        reporter.Add(new Act(String.Format("Click submenu item <b>{0}</b> under <b>{1}</b> menu", subMenu, menu)));

                        //Clicks submenu
                        Selenide.Click(driver, Locator.Get(LocatorType.XPath,
                                                           string.Format(@"//div[@class='menu']/ul/li/a[contains(text(),'{0}')]/following-sibling::ul/li[{1}]/a", menu, subMenuCount)));
                        AcceptOrDissmissAlertIfPresent(driver, reporter);
                        //Thread.Sleep(5000);
                        Selenide.WaitForElementNotVisible(driver, Locator.Get(LocatorType.ClassName, "dlg_spinner"));
                        Selenide.WaitForElementNotVisible(driver, Util.GetLocator("Spinner1_img"));
                        Selenide.WaitForElementNotVisible(driver, Util.GetLocator("Spinner2_img"));
                        AcceptErrorMessageIfPresent(driver);
                        if (Selenide.IsElementExists(driver, Util.GetLocator("Spinner1_img")) ||
                            Selenide.IsElementExists(driver, Util.GetLocator("Spinner2_img")))
                        {
                            Thread.Sleep(5000);
                        }
                        //WaitUntilSpinnerDisappears(driver);
                        CloseBrowserNewTab(driver);
                        Selenide.Focus(driver, Locator.Get(LocatorType.XPath, string.Format(@"//td[@class='left']")));

                        //Clicks external applications
                        ClickExternalApplicationMenus(driver, reporter, resultsPath);
                        Thread.Sleep(500);
                    }
                }
                if (subMenuAttribute == null)
                {
                    string submenuname = string.Empty;
                    while (submenuname == null || submenuname == string.Empty)
                    {
                        //Clicks menu
                        Selenide.Click(driver, Locator.Get(LocatorType.XPath, string.Format
                                                               (@"//div[@class='menu']/ul/li/a[contains(text(),'{0}')]", menu)));

                        Thread.Sleep(250);
                        submenuname = Selenide.GetText(driver, Locator.Get(LocatorType.XPath, string.Format
                                                                               (@"//div[@class='menu']/ul/li/a[contains(text(),'{0}')]/following-sibling::ul/li[{1}]/a/span", menu, subMenuCount)), Selenide.ControlType.Label);
                    }
                    reporter.Add(new Act(string.Format(@"Sub Menu Name is: <b>{0}</b>", submenuname)));

                    //Clicks menu
                    Selenide.Click(driver, Locator.Get(LocatorType.XPath,
                                                       string.Format(@"//div[@class='menu']/ul/li/a[contains(text(),'{0}')]", menu)));

                    //Clicks submenu1
                    Selenide.Click(driver, Locator.Get(LocatorType.XPath, string.Format
                                                           (@"//div[@class='menu']/ul/li/a[contains(text(),'{0}')]/following-sibling::ul/li[{1}]/a", menu, subMenuCount)));

                    //Number of submenu2 in submenu1
                    linksCountInSubMenu1 = Selenide.GetElementCount(driver, Locator.Get(LocatorType.XPath, string.Format
                                                                                            (@"//div[@class='menu']/ul/li/a[contains(text(),'{0}')]/following-sibling::ul/li[{1}]/ul/li/a", menu, subMenuCount)));

                    for (int eachSubLink = 1; eachSubLink <= linksCountInSubMenu1; eachSubLink++)
                    {
                        //Clicks menu
                        Selenide.Click(driver, Locator.Get(LocatorType.XPath, string.Format
                                                               (@"//div[@class='menu']/ul/li/a[contains(text(),'{0}')]", menu)));

                        //Clicks submenu1
                        Selenide.Click(driver, Locator.Get(LocatorType.XPath, string.Format
                                                               (@"//div[@class='menu']/ul/li/a[contains(text(),'{0}')]/following-sibling::ul/li[{1}]/a", menu, subMenuCount)));

                        string sublinkname = Selenide.GetText(driver, Locator.Get(LocatorType.XPath, string.Format
                                                                                      (@"//div[@class='menu']/ul/li/a[contains(text(),'{0}')]/following-sibling::ul/li[{1}]/ul/li[{2}]/a", menu, subMenuCount, eachSubLink)), Selenide.ControlType.Label);

                        reporter.Add(new Act(String.Format
                                                 ("Click submenu link " + "<b>" + "{0}" + "</b>" + " of " + "<b>" + "{1}" + "</b>" + " submenu under " + "<b>" + "{2}" + "</b>" + " menu", sublinkname, submenuname, menu)));

                        //Clicks submenu2
                        Selenide.Click(driver, Locator.Get(LocatorType.XPath, string.Format
                                                               (@"//div[@class='menu']/ul/li/a[contains(text(),'{0}')]/following-sibling::ul/li[{1}]/ul/li[{2}]/a", menu, subMenuCount, eachSubLink)));

                        AcceptOrDissmissAlertIfPresent(driver, reporter);
                        AcceptErrorMessageIfPresent(driver);

                        Selenide.WaitForElementNotVisible(driver, Locator.Get(LocatorType.ClassName, "dlg_spinner"));
                        Selenide.WaitForElementNotVisible(driver, Util.GetLocator("Spinner1_img"));
                        Selenide.WaitForElementNotVisible(driver, Util.GetLocator("Spinner2_img"));

                        WaitUntilSpinnerDisappears(driver);
                        if (Selenide.IsElementExists(driver, Util.GetLocator("Spinner1_img")) ||
                            Selenide.IsElementExists(driver, Util.GetLocator("Spinner2_img")))
                        {
                            Thread.Sleep(5000);
                        }
                        CloseBrowserNewTab(driver);
                        ClickExternalApplicationMenus(driver, reporter, resultsPath);
                    }
                }
            }
        }
Example #23
0
        /// <summary>
        /// ClickContentLinks method clicks the content links in the WebPortal
        /// </summary>
        /// <param name="driver"></param>
        /// <param name="reporter"></param>
        public static void ClickExternalApplicationMenus(RemoteWebDriver driver, Iteration reporter, string resultsPath)
        {
            int    ExternalMenuCount, LinksCountInExternalMenu;
            bool   IsExternalApplication;
            int    NumberOfExternalMenu;
            int    NumberOfSubmenuInExternalMenu;
            string LinkTextInExternalMenu;
            string ExternalMenuText;
            string submenu1 = string.Empty;

            //Checks for external application
            IsExternalApplication = Selenide.IsElementExists(driver, Locator.Get(LocatorType.XPath, "//div[@class='secmenu']/ul/li/a"));
            if (IsExternalApplication)
            {
                //Counts number of Menu's in external application
                NumberOfExternalMenu = Selenide.GetElementCount(driver, Locator.Get(LocatorType.XPath, "//div[@class='secmenu']/ul/li/a"));
                for (ExternalMenuCount = 1; ExternalMenuCount <= NumberOfExternalMenu; ExternalMenuCount++)
                {
                    //Clicks a menu in external application
                    Selenide.Click(driver, Locator.Get(LocatorType.XPath, string.Format(@"//div[@class='secmenu']/ul/li[{0}]/a", ExternalMenuCount + 1)));

                    Thread.Sleep(1000);
                    ExternalMenuText = Selenide.GetText(driver, Locator.Get(LocatorType.XPath, string.Format
                                                                                (@"//div[@class='secmenu']/ul/li[{0}]/a", ExternalMenuCount + 1)), Selenide.ControlType.Label);

                    reporter.Add(new Act(string.Format(@"Click on <b>{0}</b> menu in the external application", ExternalMenuText)));

                    Selenide.Click(driver, Locator.Get(LocatorType.XPath, string.Format(@"//div[@class='secmenu']/ul/li[{0}]/a", ExternalMenuCount + 1)));

                    NumberOfSubmenuInExternalMenu = Selenide.GetElementCount(driver, Locator.Get(LocatorType.XPath, string.Format
                                                                                                     (@"//div[@class='secmenu']/ul/li[{0}]/ul/li", ExternalMenuCount + 1)));

                    reporter.Add(new Act(string.Format
                                             (@"Menu count in each external application(Ex: SIM): <b>{0}</b>", NumberOfSubmenuInExternalMenu)));

                    for (LinksCountInExternalMenu = 1; LinksCountInExternalMenu <= NumberOfSubmenuInExternalMenu; LinksCountInExternalMenu++)
                    {
                        Selenide.Click(driver, Locator.Get(LocatorType.XPath, string.Format
                                                               (@"//div[@class='secmenu']/ul/li[{0}]/a", ExternalMenuCount + 1)));

                        LinkTextInExternalMenu = Selenide.GetText(driver, Locator.Get(LocatorType.XPath, string.Format
                                                                                          (@"//div[@class='secmenu']/ul/li[{0}]/ul/li[{1}]", ExternalMenuCount + 1, LinksCountInExternalMenu)), Selenide.ControlType.Label);

                        reporter.Add(new Act(string.Format
                                                 (@"Click on " + "<b>" + "{0}" + "</b>" + " submenu In the external application", LinkTextInExternalMenu)));

                        try
                        {
                            Selenide.Click(driver, Locator.Get(LocatorType.XPath, string.Format
                                                                   (@"//div[@class='secmenu']/ul/li[{0}]/a", ExternalMenuCount + 1)));

                            Selenide.Click(driver, Locator.Get(LocatorType.XPath, string.Format
                                                                   (@"//div[@class='secmenu']/ul/li[{0}]/ul/li[{1}]/a", ExternalMenuCount + 1, LinksCountInExternalMenu)));

                            AcceptOrDissmissAlertIfPresent(driver, reporter);
                            AcceptErrorMessageIfPresent(driver);

                            Selenide.WaitForElementNotVisible(driver, Locator.Get(LocatorType.ClassName, "dlg_spinner"));
                            Selenide.WaitForElementNotVisible(driver, Util.GetLocator("Spinner1_img"));
                            Selenide.WaitForElementNotVisible(driver, Util.GetLocator("Spinner2_img"));

                            CloseBrowserNewTab(driver);
                            Selenide.Focus(driver, Locator.Get(LocatorType.XPath, string.Format(@"//td[@class='left']")));
                            //Thread.Sleep(1000);
                        }
                        catch (Exception ex)
                        {
                            reporter.Add(new Act(string.Format
                                                     (@"Error found in external application menu link: <b>{0}</b>", LinkTextInExternalMenu)));

                            CommonPage.TakeScreenShotAndAttachToReport(driver, LinkTextInExternalMenu, resultsPath, reporter);
                        }
                    }
                }
            }
        }
Example #24
0
 /// <summary>
 /// Click Project Account Information Link
 /// </summary>
 public static void ClickAccountTopMenuLink(RemoteWebDriver driver, Iteration reporter, string data)
 {
     Selenide.Click(driver, Locator.Get(LocatorType.XPath, "//a[contains(text(),'" + data + "')]"));
 }