Esempio n. 1
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);
            }
        }
Esempio n. 2
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);
                    }
                }
            }
        }
Esempio n. 3
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);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
 /// <summary>
 /// MenuNames returns menu text of menu link
 /// </summary>
 /// <param name="driver"></param>
 /// <param name="reporter"></param>
 /// <param name="postion">Position of the link </param>
 /// <returns></returns>
 public static string GetMenuNames(RemoteWebDriver driver, Iteration reporter,
                                   int menuName)
 {
     //reporter.Add(new Act(string.Format(@"Gets the menu names")));
     return(Selenide.GetText(driver, Locator.Get(LocatorType.XPath, string.Format(@"//div[@class='menu']/ul/li[{0}]", menuName)), Selenide.ControlType.Label));
 }