示例#1
0
        public void GoogleAssociation()
        {
            //Arrange
            String orgname       = "hotline"; //organization to check name
            String searchname    = "rozetka"; //string to search
            bool   IsAssosiated  = true;      //defines test for checking of association or unassotiation (if true, will take screenshot only for page, where organization link was found, if false - for every page)
            bool   OnlyFirstPage = false;     //if true, only first page will be checked, else - all

            //Act
            var        ResultsPage = new ResultsPage(driver);
            var        SearchPage  = new GoogleSearchPage(driver);
            var        pagenumber  = 0;
            var        boolia      = false;
            IWebDriver driver0     = new PhantomJSDriver();

            SearchPage.Search(searchname);

            do
            {
                pagenumber++;
                if (!IsAssosiated)
                {
                    ResultsPage.TakeScreenshot(driver0);
                }
                if (ResultsPage.ItISOnPage(orgname))
                {
                    boolia = true;
                    if (IsAssosiated)
                    {
                        ResultsPage.TakeScreenshot(driver0);
                    }
                    break;
                }
            } while ((ResultsPage.NextPage() && !OnlyFirstPage));

            //Assert
            driver0.Quit();
            Console.WriteLine("Number of checked pages: " + pagenumber);
            Assert.IsTrue(boolia ^ !IsAssosiated);
        }