Example #1
0
 public static void CheckArticleCount(BrowserWrapper browser, string repeaterUiId, int expectedCount)
 {
     var articles = browser.First($"div[data-ui='{repeaterUiId}']").FindElements("article[data-ui='test-article']");
     if (articles.Count != expectedCount)
     {
         throw new UnexpectedElementStateException($"There should be only 2 article in the repeater. There are {articles.Count}");
     }
 }
Example #2
0
 private void Control_GridViewShowHeaderWhenNoData(BrowserWrapper browser)
 {
     browser.FindElements("[data-ui='ShowHeaderWhenNoDataGrid']").FindElements("th").First().IsDisplayed();
 }
 private static void CheckIfInnerTextEqualsToOne(BrowserWrapper browser, string dataUi)
 {
     browser.FindElements($"[data-ui='{dataUi}']").First().CheckIfInnerTextEquals(1.ToString());
 }
Example #4
0
 private static void ChangeAndTestLocalization(BrowserWrapper browser)
 {
     browser.First("p").CheckIfInnerTextEquals("This comes from resource file!", false, true);
     // change language
     browser.Last("a").Click();
     browser.First("p").CheckIfInnerTextEquals("Tohle pochází z resource souboru!", false, true);
 }
Example #5
0
        private void TryExecuteTest(Action<BrowserWrapper> action, IWebDriverFactory browserFactory, out string browserName, out Exception exception)
        {
            var attemptNumber = 0;
            do
            {
                attemptNumber++;
                exception = null;
                using (var browser = browserFactory.CreateNewInstance())
                {
                    helper = new BrowserWrapper(browser.Driver, this);
                    browserName = browser.GetType().Name;

                    WriteLine($"Testing browser '{browserName}' attempt no. {attemptNumber}");

                    try
                    {
                        action(helper);
                    }
                    catch (Exception ex)
                    {
                        bool isExpected = false;
                        if (ExpectedExceptionType != null)
                        {
                            isExpected = ex.GetType() == ExpectedExceptionType || (AllowDerivedExceptionTypes && ExpectedExceptionType.IsInstanceOfType(ex));
                        }

                        if (!isExpected)
                        {
                            TakeScreenshot(attemptNumber, helper);
                            // fail the test
                            exception = ex;
                        }
                    }
                }
            }
            while (exception != null && attemptNumber == SeleniumTestsConfiguration.TestAttemps);
        }
Example #6
0
        protected virtual void TakeScreenshot(int attemptNumber, BrowserWrapper browserWrapper)
        {
            // make screenshot
            try
            {

                LogCurrentlyPerformedAction("Taking screenshot");

                var filename = Path.Combine(ScreenshotsFolderPath, $"{TestContext.FullyQualifiedTestClassName}_{TestContext.TestName}" + attemptNumber + ".png");
                browserWrapper.TakeScreenshot(filename);
                TestContext.AddResultFile(filename);

            }
            catch
            {
                //ignore
            }
        }
Example #7
0
 public static ElementWrapperCollection ToElementsList(this IEnumerable<IWebElement> elements, BrowserWrapper browserWrapper, string selector, ElementWrapper elementWrapper)
 {
     return new ElementWrapperCollection(elements.Select(s => new ElementWrapper(s, browserWrapper)), selector, elementWrapper);
 }
Example #8
0
 public void SubSectionAction(BrowserWrapper browser)
 {
     browser.FindElements("form").FindElements("div").ThrowIfDifferentCountThan(111);
 }