public void AddPageTog(Page page)
    {
        GameObject obj     = Instantiate(PagePrefab, PagePrefab.transform.position, PagePrefab.transform.rotation) as GameObject;
        PageBtn    pageBtn = obj.GetComponent <PageBtn>();

        pageBtn.page         = page;
        obj.transform.parent = PageContent.transform;
        obj.SetActive(true);
        pageBtn.Click(obj.GetComponent <Toggle>());
    }
Exemple #2
0
        public void NaverMoveResultPage(int ScanPage)
        {
            if (SwitchToSearchTab() == false)
            {
                Console.WriteLine("검색텝이 네이버가 아닙니다");
                return;
            }

            Thread.Sleep(1000);

            if (driver.FindElements(By.CssSelector("span[class='title_num']")).Count == 0)
            {
                Console.WriteLine("통합검색에는 페이지가 없습니다");
                return;
            }

            string DocCount = driver.FindElement(By.CssSelector("span[class='title_num']")).Text;

            for (int i = 0; i < DocCount.Length; i++)
            {
                if (DocCount.Substring(i, 1) == "/")
                {
                    DocCount = DocCount.Substring(i + 2).Replace("건", "").Replace(",", "");
                    break;
                }
            }
            double      PageCount = Math.Ceiling(Convert.ToDouble(DocCount) / 10);
            IWebElement thisPage  = driver.FindElement(By.CssSelector("div[class='paging'] strong"));

            if (PageCount < ScanPage || 100 < ScanPage)
            {
                Console.WriteLine("존재하지 않는 페이지 입니다");
                return;
            }

            if (thisPage.Text == ScanPage.ToString())
            {
                Console.WriteLine("현재 페이지가" + ScanPage + "입니다");
            }

            var PageBtnElement = driver.FindElements(By.CssSelector("div[class='paging'] a"));

            foreach (var PageBtn in PageBtnElement)
            {
                if (PageBtn.Text == ScanPage.ToString())
                {
                    PageBtn.Click();
                    return;
                }
            }

            Actions actions = new Actions(driver);

            IWebElement CoLowerNumBtn = null;

            foreach (var PageBtn in PageBtnElement)
            {
                if (PageBtn.Text == "이전페이지" || PageBtn.Text == "다음페이지")
                {
                    continue;
                }

                if (CoLowerNumBtn == null)
                {
                    CoLowerNumBtn = PageBtn;
                }
                else if (Convert.ToInt16(PageBtn.Text) < Convert.ToInt16(CoLowerNumBtn.Text))
                {
                    CoLowerNumBtn = PageBtn;
                }
            }
            IWebElement CoHigherNumBtn = null;

            foreach (var PageBtn in PageBtnElement)
            {
                if (PageBtn.Text == "이전페이지" || PageBtn.Text == "다음페이지")
                {
                    continue;
                }

                if (CoHigherNumBtn == null)
                {
                    CoHigherNumBtn = PageBtn;
                }
                else if (Convert.ToInt16(PageBtn.Text) > Convert.ToInt16(CoHigherNumBtn.Text))
                {
                    CoHigherNumBtn = PageBtn;
                }
            }

            if (Convert.ToInt16(CoLowerNumBtn.Text) > ScanPage)//찾을 페이지가 뒤<에 있을때
            {
                actions = new Actions(driver);
                actions.MoveToElement(driver.FindElement(By.CssSelector("div[class='paging']"))).Perform();

                while (true)
                {
                    PageBtnElement = driver.FindElements(By.CssSelector("div[class='paging'] a"));
                    IWebElement LowerNumBtn = null;
                    foreach (var PageBtn in PageBtnElement)
                    {
                        if (PageBtn.Text == "이전페이지" || PageBtn.Text == "다음페이지")
                        {
                            continue;
                        }

                        if (LowerNumBtn == null)
                        {
                            LowerNumBtn = PageBtn;
                        }
                        else if (Convert.ToInt16(PageBtn.Text) < Convert.ToInt16(LowerNumBtn.Text))
                        {
                            LowerNumBtn = PageBtn;
                        }
                    }
                    LowerNumBtn.Click();

                    Thread.Sleep(1000);

                    actions = new Actions(driver);
                    actions.MoveToElement(driver.FindElement(By.CssSelector("div[class='paging']"))).Perform();

                    PageBtnElement = driver.FindElements(By.CssSelector("div[class='paging'] a"));
                    foreach (var PageBtn in PageBtnElement)
                    {
                        if (PageBtn.Text == ScanPage.ToString())
                        {
                            PageBtn.Click();
                            return;
                        }
                    }

                    thisPage = driver.FindElement(By.CssSelector("div[class='paging'] strong"));
                    if (thisPage.Text == ScanPage.ToString())
                    {
                        return;
                    }
                }
            }

            else if (Convert.ToInt16(CoHigherNumBtn.Text) < ScanPage)//찿을 페이지가 앞>에 있을때
            {
                actions = new Actions(driver);
                actions.MoveToElement(driver.FindElement(By.CssSelector("div[class='paging']"))).Perform();

                while (true)
                {
                    PageBtnElement = driver.FindElements(By.CssSelector("div[class='paging'] a"));
                    IWebElement HigherNumBtn = null;
                    foreach (var PageBtn in PageBtnElement)
                    {
                        if (PageBtn.Text == "이전페이지" || PageBtn.Text == "다음페이지")
                        {
                            continue;
                        }

                        if (HigherNumBtn == null)
                        {
                            HigherNumBtn = PageBtn;
                        }
                        else if (Convert.ToInt16(PageBtn.Text) > Convert.ToInt16(HigherNumBtn.Text))
                        {
                            HigherNumBtn = PageBtn;
                        }
                    }
                    HigherNumBtn.Click();

                    Thread.Sleep(1000);

                    actions = new Actions(driver);
                    actions.MoveToElement(driver.FindElement(By.CssSelector("div[class='paging']"))).Perform();

                    PageBtnElement = driver.FindElements(By.CssSelector("div[class='paging'] a"));
                    foreach (var PageBtn in PageBtnElement)
                    {
                        if (PageBtn.Text == ScanPage.ToString())
                        {
                            PageBtn.Click();
                            return;
                        }
                    }

                    thisPage = driver.FindElement(By.CssSelector("div[class='paging'] strong"));
                    if (thisPage.Text == ScanPage.ToString())
                    {
                        return;
                    }
                }
            }
        }