Пример #1
0
        public void CanSelectFromBrowserActionLine()
        {
            var act1      = "click";
            var selector1 = "xpath";
            var locator1  = "//html";
            var list      = new List <Token>()
            {
                new Token(Token.TokenType.TOKEN_ACTION, 0, act1),
                new Token(Token.TokenType.TOKEN_ACTION, 1, selector1),
                new Token(Token.TokenType.TOKEN_ACTION, 2, locator1),
                new Token(Token.TokenType.TOKEN_EOE, 3, null)
            };
            var browserActionLine = new BrowserActionLine(list);

            WebBrowser browser = new LoggingBrowser(new WebBrowser());

            browser.Start(BrowserList.Chrome);
            // browser.GoTo("https://www.reddit.com");
            DoAction by;

            foreach (var line in browserActionLine.ActionLines)
            {
                by = new DoAction(ref browser, line.Action);
                ActionStrategy actionStrategy = by.SelectBy(line.By);
                Assert.NotNull(actionStrategy);
            }

            browser.Quit();
        }
Пример #2
0
        public void CanCreateALoggingBrowser()
        {
            // Test assumes that chromedriver is installed and on the PATH, and able to be run.
            WebBrowser b = new LoggingBrowser(new WebBrowser());

            b.Start(BrowserList.Chrome);
            Assert.NotNull(b.GetDriver());
            b.Quit();
        }
Пример #3
0
        public void CanNavigateThroughAUserFlow()
        {
            WebBrowser browser = new LoggingBrowser(new WebBrowser());

            browser.Start(BrowserList.Chrome);
            browser.GoTo("https://www.reddit.com");
            By loginBtnBy = By.XPath("//*[text() = 'Log In']");

            browser.FindElement(loginBtnBy).Click();
            browser.Quit();
        }
Пример #4
0
        public void CanRunASeleniumTest()
        {
            var        tea     = new TeaFile("./../../../Resources/LoginWithFailingUsername.tea");
            WebBrowser browser = new LoggingBrowser(new WebBrowser());

            browser.Start(BrowserList.Chrome);
            browser.GoTo(tea.URL);

            foreach (var line in tea.ActionLines)
            {
                DoAction       doAction = new DoAction(ref browser, line.Action);
                ActionStrategy strategy = doAction.SelectBy(line.By);
                strategy.Execute(line.Text);
            }

            browser.Quit();
        }
Пример #5
0
        public void iFramesTest()
        {
            By loginBtnBy = By.XPath("//*[text() = 'Log In']");
            By loginTxtBy = By.XPath("//*[@id='loginUsername']");

            string     url     = "http://www.reddit.com";
            WebBrowser browser = new LoggingBrowser(new WebBrowser());

            browser.Start(BrowserList.Chrome);
            browser.GoTo(url);

            browser.FindElement(loginBtnBy).Click();

            Element usernameTextField = browser.FindElement(loginTxtBy);

            usernameTextField?.TypeText("derp");

            browser.Quit();
        }
Пример #6
0
        private static void SeleniumTest(string path)
        {
            string     testFilePath = "Resources/LoginWithFailingUsername.tea";
            var        tea          = new TeaFile(path);
            WebBrowser browser      = new LoggingBrowser(new WebBrowser());

            browser.Start(BrowserList.Chrome);
            browser.GoTo(tea.URL);

            try
            {
                foreach (var line in tea.ActionLines)
                {
                    new DoAction(ref browser, line.Action).SelectBy(line.By)
                    .Execute(line.Text);
                }
            } finally {
                browser.Quit();
            }
        }