Esempio n. 1
0
        public void AssertUrlEquals(string expectedUrl)
        {
            string stepDescription = string.Format("Assert URL equals '{0}'", expectedUrl);

            string actualUrl = GetCurrentUrl();

            Asserter.AssertThat(actualUrl, Is.EqualTo(expectedUrl), stepDescription);
        }
Esempio n. 2
0
        public void AssertUrlContains(string expectedUrl)
        {
            string stepDescription = string.Format("Assert URL contains '{0}'", expectedUrl);

            string actualUrl = GetCurrentUrl();

            Asserter.AssertThat(actualUrl, Does.Contain(expectedUrl), stepDescription);
        }
Esempio n. 3
0
        public void AssertTitleIsCorrect(string expectedTitle)
        {
            string stepDescription = string.Format("Assert page title equals '{0}'", expectedTitle);

            string actualTitle = GetTitle();

            Asserter.AssertThat(actualTitle, Is.EqualTo(expectedTitle), stepDescription);
        }
Esempio n. 4
0
        public void AssertElementIsEnabled()
        {
            string      stepDecription = TestLogger.CreateTestStep("Assert Element is Enabled", name, pageName);
            IWebElement webElement     = null;

            try
            {
                webElement = FindWebElement();
            }
            catch (Exception ex)
            {
                TestHelper.HandleActionOrAssertionException(stepDecription, ex);
            }

            Asserter.AssertThat(webElement.Enabled, Is.True, stepDecription, false);
        }
Esempio n. 5
0
        public void AssertElementTextIsPopulted()
        {
            string stepDecription = TestLogger.CreateTestStep("Assert Element Text Is Populated", name, pageName);
            string actualtext     = string.Empty;

            try
            {
                actualtext = FindWebElement().Text;
            }
            catch (Exception ex)
            {
                TestHelper.HandleActionOrAssertionException(stepDecription, ex);
            }

            actualtext = actualtext.Replace(" ", string.Empty);
            Asserter.AssertThat(actualtext.Length > 0, Is.True, stepDecription, false);
        }
Esempio n. 6
0
        public void AssertElementTextDoesNotContain(string containsText)
        {
            string actionDescription = string.Format("Assert Element Text Does Not Contain '{0}'", containsText);
            string stepDecription    = TestLogger.CreateTestStep(actionDescription, name, pageName);
            string actualtext        = string.Empty;

            try
            {
                actualtext = FindWebElement().Text;
            }
            catch (Exception ex)
            {
                TestHelper.HandleActionOrAssertionException(stepDecription, ex);
            }

            Asserter.AssertThat(actualtext, Does.Not.Contain(containsText), stepDecription, false);
        }
Esempio n. 7
0
        public void AssertElementAttributeContains(string attribute, string containsText)
        {
            string actionDescription = string.Format("Assert Element Attribute {0} Contains '{1}'", attribute, containsText);
            string stepDecription    = TestLogger.CreateTestStep(actionDescription, name, pageName);
            string elementAttribute  = string.Empty;

            try
            {
                elementAttribute = FindWebElement().GetAttribute(attribute);
            }
            catch (Exception ex)
            {
                TestHelper.HandleActionOrAssertionException(stepDecription, ex);
            }

            Asserter.AssertThat(elementAttribute, Does.Contain(containsText), stepDecription, false);
        }
Esempio n. 8
0
        public void AssertElementValueEquals(string expectedValue)
        {
            string actionDescription = string.Format("Assert Element Value Equals '{0}'", expectedValue);
            string stepDecription    = TestLogger.CreateTestStep(actionDescription, name, pageName);
            string actualText        = string.Empty;

            try
            {
                actualText = FindWebElement().GetAttribute("value");
            }
            catch (Exception ex)
            {
                TestHelper.HandleActionOrAssertionException(stepDecription, ex);
            }

            Asserter.AssertThat(actualText, Is.EqualTo(expectedValue), stepDecription, false);
        }
Esempio n. 9
0
        public void AssertElementTextMatches(string pattern)
        {
            string actionDescription = string.Format("Assert Element Text Matches Regex Pattern '{0}'", pattern);
            string stepDecription    = TestLogger.CreateTestStep(actionDescription, name, pageName);
            bool   matches           = false;

            try
            {
                Regex regex = new Regex(pattern);
                matches = regex.IsMatch(FindWebElement().Text);
            }
            catch (Exception ex)
            {
                TestHelper.HandleActionOrAssertionException(stepDecription, ex);
            }

            Asserter.AssertThat(matches, Is.True, stepDecription, false);
        }
Esempio n. 10
0
        public void AssertElementTextContainsNumericCharacters()
        {
            string stepDecription = TestLogger.CreateTestStep("Assert Element Text Contains Numeric Characters", name, pageName);
            string actualtext     = string.Empty;

            try
            {
                actualtext = FindWebElement().Text;
            }
            catch (Exception ex)
            {
                TestHelper.HandleActionOrAssertionException(stepDecription, ex);
            }

            bool containsNumericCharacters = actualtext.Any(char.IsDigit);

            Asserter.AssertThat(containsNumericCharacters, Is.True, stepDecription, false);
        }
Esempio n. 11
0
        public void AssertElementHasAttribute(string attribute)
        {
            string actionDescription = string.Format("Assert Element Has Attribute '{0}'", attribute);
            string stepDecription    = TestLogger.CreateTestStep(actionDescription, name, pageName);

            bool hasAttribute = false;

            try
            {
                string attributeValue = FindWebElement().GetAttribute(attribute);
                hasAttribute = (attribute != null);
            }
            catch (Exception ex)
            {
                TestHelper.HandleActionOrAssertionException(stepDecription, ex);
            }

            Asserter.AssertThat(hasAttribute, Is.True, stepDecription, false);
        }
Esempio n. 12
0
        public void AssertElementTextContainsValidDateFormat(string dateFormat)
        {
            string actionDescription = string.Format("Assert Element Text Contains Date Format : {0}", dateFormat);
            string stepDescription   = TestLogger.CreateTestStep(actionDescription, name, pageName);

            try
            {
                DateTime dateTimeOut = DateTime.Now;

                CultureInfo provider      = CultureInfo.InvariantCulture;
                bool        matchesFormat = DateTime.TryParseExact(FindWebElement().Text,
                                                                   dateFormat,
                                                                   provider,
                                                                   DateTimeStyles.None, out dateTimeOut);
                Asserter.AssertThat(matchesFormat, Is.True, stepDescription, false);
            }
            catch (Exception ex)
            {
                TestHelper.HandleActionOrAssertionException(stepDescription, ex);
            }
        }
Esempio n. 13
0
        public void AssertElementIsNotEditable()
        {
            string stepDecription = TestLogger.CreateTestStep("Assert Element is Not Editable", name, pageName);

            IWebElement element           = null;
            string      disabledAttribute = string.Empty;

            try
            {
                element           = WebDriverHelper.Driver.FindElement(locator);
                disabledAttribute = element.GetAttribute("disabled");
            }
            catch (Exception ex)
            {
                TestHelper.HandleActionOrAssertionException(stepDecription, ex);
            }

            bool isDisabled = bool.Parse(disabledAttribute);

            Asserter.AssertThat(isDisabled, Is.True, stepDecription, false);
        }
Esempio n. 14
0
        public void AssertElementAttributeMatches(string attribute, string pattern)
        {
            string actionDescription = string.Format("Assert Element Text Matches Regex Pattern '{0}'", pattern);
            string stepDecription    = TestLogger.CreateTestStep(actionDescription, name, pageName);

            string attributeValue = string.Empty;
            Regex  regex          = null;

            try
            {
                attributeValue = FindWebElement().GetAttribute(attribute);
                regex          = new Regex(pattern);
            }
            catch (Exception ex)
            {
                TestHelper.HandleActionOrAssertionException(stepDecription, ex);
            }

            bool matches = regex.IsMatch(attributeValue);

            Asserter.AssertThat(matches, Is.True, stepDecription, false);
        }
Esempio n. 15
0
        public void AssertElementTextEquals(string expectedText, bool caseSensitive = true)
        {
            string actionDescription = string.Format("Assert Element Text Equals '{0}'", expectedText);
            string stepDecription    = TestLogger.CreateTestStep(actionDescription, name, pageName);
            string actualText        = string.Empty;

            try
            {
                actualText = FindWebElement().Text;
            }
            catch (Exception ex)
            {
                TestHelper.HandleActionOrAssertionException(stepDecription, ex);
            }
            if (caseSensitive)
            {
                Asserter.AssertThat(actualText, Is.EqualTo(expectedText), stepDecription, false);
            }
            else
            {
                Asserter.AssertThat(actualText, Is.EqualTo(expectedText).IgnoreCase, stepDecription, false);
            }
        }
Esempio n. 16
0
        public void AssertElementIsNotDisplayed()
        {
            string stepDecription = TestLogger.CreateTestStep("Assert Element is Not Displayed", name, pageName);

            bool elementFound = false;

            try
            {
                IWebElement webElement = FindWebElement();
                elementFound = true;
            }
            catch (NoSuchElementException)
            {
                //Swallow exception - We expect FindElement() to throw NoSuchElementException if
                //no web elements in the DOM match the By search query
            }
            catch (Exception ex)
            {
                //Throw any other unexpected exception types
                TestHelper.HandleActionOrAssertionException(stepDecription, ex);
            }

            Asserter.AssertThat(elementFound, Is.False, stepDecription, false);
        }
Esempio n. 17
0
        public void AssertElementTextContains(string contains, bool caseSensitive = true)
        {
            string actionDescription = string.Format("Assert Element Text Contains '{0}'", contains);
            string stepDecription    = TestLogger.CreateTestStep(actionDescription, name, pageName);
            string elementText       = string.Empty;

            try
            {
                elementText = FindWebElement().Text;
            }
            catch (Exception ex)
            {
                TestHelper.HandleActionOrAssertionException(stepDecription, ex);
            }

            if (caseSensitive)
            {
                Asserter.AssertThat(elementText, Does.Contain(contains), stepDecription, false);
            }
            else
            {
                Asserter.AssertThat(elementText, Does.Contain(contains).IgnoreCase, stepDecription, false);
            }
        }