예제 #1
0
        public int goTo_MyReportsPage()
        {
            Thread.Sleep(20000);


            String Xpath1 = "//ul[@class='nav']";
            String Xpath2 = "div[@class='subNav']";

            List <IWebElement> Menus = new List <IWebElement>();

            Menus = MyReportDriver.FindElement(By.XPath(Xpath1)).FindElements(By.TagName("li")).ToList();


            IWebElement Menu    = null;
            IWebElement SubMenu = null;


            for (int i = 0; i <= MyReportDriver.FindElement(By.XPath(Xpath1)).FindElements(By.TagName("li")).Count; i++)
            {
                Menu = Menus.ElementAt(i);
                if (Menu.Text.Equals("REPORTS"))
                {
                    break;
                }
            }


            IWebElement Report = Menu;


            String strJavaScript = "var element = arguments[0];"
                                   + "var mouseEventObj = document.createEvent('MouseEvents');"
                                   + "mouseEventObj.initEvent( 'mouseover', true, true );"
                                   + "element.dispatchEvent(mouseEventObj);";

            ////Then JavascriptExecutor class is used to execute the script to trigger the dispatched event.
            ((IJavaScriptExecutor)MyReportDriver).ExecuteScript(strJavaScript, Report);


            List <IWebElement> SubMenus = Report.FindElements(By.XPath(Xpath2)).ToList().ElementAt(0).FindElement(By.ClassName("subNav")).FindElements(By.TagName("li")).ToList();


            for (int j = 0; j <= SubMenus.Count(); j++)
            {
                SubMenu = SubMenus.ElementAt(j);
                if (SubMenu.Text.Equals("My Reports"))
                {
                    break;
                }
            }

            IWebElement MyReport = SubMenu;

            bu.mouseOverClick(MyReportDriver, MyReport, true);
            return(1);
        }