Ejemplo n.º 1
0
        public void SearchTheWordClick()
        {
            #region Variables

            Logger1 newLog1 = new Logger1();
            newLog1.CreateStory(driver, MethodBase.GetCurrentMethod().Name, GetTestDescription(MethodBase.GetCurrentMethod().CustomAttributes));
            string wordToSearch         = "Click";
            string textResultfromDialog = string.Empty;
            string textResulFromPage    = string.Empty;
            int    timeout = 1;

            #endregion

            #region Navigate to Home Page and Click "API" Button from NavBar

            HomePage homePage = new HomePage(driver);
            homePage.Navigate();
            var         аpiPage   = homePage.GoToAPIPage();
            DialogPages newSearch = аpiPage.OpenSearch(wordToSearch);

            #endregion

            #region Fill the word "Click" in Search Dialog

            newSearch.SearchTextField = "Click";
            Thread.Sleep(TimeSpan.FromSeconds(1));
            newLog1.Step("Fill the word 'Click' in Search Dialog", driver);

            //This while is used for timeout
            while (newSearch.SearchTextField != "Click" || timeout > 10)
            {
                Thread.Sleep(TimeSpan.FromSeconds(2));
                timeout++;
            }

            textResultfromDialog = newSearch.GetSearchResultInfo;
            string numberFromDialog = Regex.Match(textResultfromDialog, @"\d+").Value;

            #endregion

            #region Navigate to Search Page and Fill The Word "Click"

            SearchPage searchPage = new SearchPage(driver);
            searchPage.Navigate();
            searchPage.FillTextForSearch(wordToSearch);
            newLog1.Step("Navigate to Search Page and Fill The Word 'Click'", driver);
            textResulFromPage = searchPage.ResultsInfo();
            string numberFromPage = Regex.Match(textResulFromPage, @"\d+").Value;

            #endregion

            #region Verify The number of results are equal on Dialog Window and Search Page

            Assert.AreEqual(numberFromPage, numberFromDialog);
            newLog1.SaveStory();

            #endregion
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            /// **** S letter Example ****
            FileHandler1 fHandler = new FileHandler1();

            fHandler.Delete("Example.txt");
            FileHandler2 fHandler2 = new FileHandler2();

            fHandler.Delete("Example.txt");

            /// **** O letter Example ****
            Logger1 logger = new Logger1();

            logger.Log("[ERROR] Print failed");
            ErrorLogger2 logger2 = new ErrorLogger2();

            logger2.Log("[ERROR] Print failed");

            /// **** L letter Example ****
            Duck duck1 = new Duck();

            duck1.Fly();
            Ostrich ostrich1 = new Ostrich();

            ostrich1.Fly();

            Duck2 duck2 = new Duck2();

            duck2.Fly();
            duck2.GetWeight();

            Ostrich2 ostrich2 = new Ostrich2();

            ostrich2.GetWeight();

            /// **** I letter Example ****
            // Just interfaces, maybe show later if I'm free and in mood :D

            /// **** O letter Example ****
            FileHandler3 fHandler3 = new FileHandler3();

            fHandler3.Delete("Example.txt");

            FileHandler4 fHandler4 = new FileHandler4();

            fHandler4.GetLogger(new Logger2());
            fHandler4.Delete("Example.txt");

            FileHandler4 fHandler4_1 = new FileHandler4();

            fHandler4.GetLogger(new ErrorLogger2());
            fHandler4.Delete("Example.txt");


            Console.ReadKey();
        }
        public void Logger1Test()
        {
            Logger1 instance1 = Logger1.GetInstance;
            Logger1 instance2 = Logger1.GetInstance;

            Assert.Same(instance1, instance1);
            instance1.Counter++;
            Assert.Equal(instance1.Counter, instance2.Counter);
            instance2.Counter++;
            Assert.Equal(instance1.Counter, instance2.Counter);
        }
Ejemplo n.º 4
0
        public void VerifyProtocolsList()
        {
            #region Variables

            Logger1 newLog1 = new Logger1();
            newLog1.CreateStory(driver, MethodBase.GetCurrentMethod().Name, GetTestDescription(MethodBase.GetCurrentMethod().CustomAttributes));
            List <string> listOfProtocols = new List <string>
            {
                "WebDriver Protocol",
                "Appium",
                "Mobile JSON Wire Protocol",
                "Chromium",
                "Sauce Labs",
                "Selenium Standalone",
                "JSON Wire Protocol"
            };

            #endregion

            #region Navigate to Home Page and Click "Protocol" section in the left navigation bar

            HomePage homePage = new HomePage(driver);
            homePage.Navigate();
            APIPage аpiPage = homePage.GoToAPIPage();
            аpiPage.ExpandProtocols();

            #endregion

            #region Get Number of Protocols and Their Names from the menu

            Thread.Sleep(TimeSpan.FromSeconds(10));
            var protocols    = аpiPage.Protocols;
            var protocolList = new List <string>();
            for (int i = 0; i < protocols.Count; i++)
            {
                protocolList.Add(protocols[i].Text);
            }

            #endregion

            #region Verify Protocol Names in Exact Order

            newLog1.Step("Protocols", driver);
            Assert.IsTrue(listOfProtocols.SequenceEqual(protocolList));
            newLog1.SaveStory();

            #endregion
        }