示例#1
0
        // IsElementNotChecked
        /// <summary>
        /// Validate if element is NOT on page and record the result in ExtentEx report.
        /// </summary>
        /// <param name="elementFactory">Factory that contains only the element that we want to validate.</param>
        /// <param name="fullElementName">Element Name.</param>
        /// <param name="secondsToWait">If the driver is not protractor driver. How much time to wait element to become clickable.</param>
        public void IsElementNotChecked(Func <IWebElement> elementFactory, string fullElementName, int secondsToWait = 30)
        {
            ElementInteractions elInt = new ElementInteractions(driver);
            IWebElement         element;

            fullElementName = DefineFullElementName(elementFactory, fullElementName);

            try
            {
                element = elementFactory();
                elInt.WaitForElement(secondsToWait, element);
                var zz = element.GetAttribute("checked");
                if ((element.GetAttribute("checked")) != "true")
                {
                    reportsLibrary.WritePassResult(fullElementName + " is NOT checked", reportTypes);
                }
                else
                {
                    reportsLibrary.WriteErrorMessageWithScreenshot(reportTypes, "fail", fullElementName + "must be NOT checked but it is checked.");
                }
            }
            catch (Exception ex)
            {
                reportsLibrary.WriteErrorMessageWithScreenshot(reportTypes, "fatal", "Element " + fullElementName + " is missing. <br><b>ErrorMessage: </b><br>" + ex.Message);
                return;
            }
        }
示例#2
0
        /// <summary>
        /// Validate if property of the element have specific value and record the result in ExtentEx report. First wait X seconds element to become clickable.
        /// </summary>
        /// <param name="elementFactory">Factory that contains only the element that we want to validate.</param>
        /// <param name="propertyName">The name of the property that we want to check.</param>
        /// <param name="expectedValue">Value that we expect the property to have.</param>
        /// <param name="fullElementName">Element Name as string.
        /// 1.)Put the name of the element as string. If the name of the element is different than method name which is in elementFactory. We use this with speckflow tests.
        /// 2.)Leave empty if the name of the method in elementFactory is the name of the element</param>
        /// <param name="secondsToWait">How many seconds to wait element to become clickable</param>
        public void ValidateProperty(Func <IWebElement> elementFactory, String propertyName, String expectedValue, string fullElementName, int secondsToWait = 30)

        {
            ElementInteractions elInt = new ElementInteractions(driver);
            IWebElement         element;

            fullElementName = DefineFullElementName(elementFactory, fullElementName);

            try
            {
                element = elementFactory();
                elInt.WaitForElement(secondsToWait, element);
                var pp = FormattRealValue(element.GetAttribute(propertyName).Trim());
                if (!pp.Equals(expectedValue.Trim()))
                {
                    reportsLibrary.WriteErrorMessageWithScreenshot(reportTypes, "fail", "Element is: " + fullElementName + ". Property Name is " + propertyName + ". Expected value is |" + expectedValue.Trim() + "|, but actuall we see |" + pp + "| ");
                }
                else
                {
                    reportsLibrary.WritePassResult("Element is: " + fullElementName + " and Property Name is " + propertyName + " and expected value is |" + expectedValue.Trim() + "|,actuall value is |" + pp + "| ", reportTypes);
                }
            }
            catch (Exception ex)
            {
                reportsLibrary.WriteErrorMessageWithScreenshot(reportTypes, "fatal", "Element " + fullElementName + " is missing. <br><b>ErrorMessage: </b><br>" + ex.Message);
                return;
            }
        }
示例#3
0
        /// <summary>
        /// Verify Displayed and Enabled statuses of the element and record the result in ExtentEx report. If you leave empty enabledStatus or displayedStatus property the method will not check this status.
        /// </summary>
        /// <param name="elementFactory">Factory that contains only the element that we want to validate.</param>
        /// <param name="fullElementName">Element Name as string.
        /// 1.)Put the name of the element as string. If the name of the element is different than method name which is in elementFactory. We use this with speckflow tests.
        /// 2.)Leave empty if the name of the method in elementFactory is the name of the element</param>
        /// <param name="enabledStatus">Expected condition of element.Enabled status. String value "true" or "false"</param>
        /// <param name="displayedStatus">Expected condition of element.Displayed status. String value "true" or "false"</param>
        /// <param name="secondsToWait">If the driver is not protractor driver. How much time to wait element to become clickable.</param>
        public void VerifyElementDisplayedEnabled(Func <IWebElement> elementFactory, string enabledStatus, string displayedStatus, string fullElementName, int secondsToWait = 30)
        {
            ElementInteractions elInt = new ElementInteractions(driver);
            IWebElement         element;

            fullElementName = DefineFullElementName(elementFactory, fullElementName);

            try
            {
                element = elementFactory();
                elInt.WaitForElement(secondsToWait, element);
                if (!(enabledStatus == string.Empty))
                {
                    if (element.Enabled.ToString().ToLower() == enabledStatus)
                    {
                        reportsLibrary.WritePassResult("For element" + fullElementName + " we expect Enabled status to be: |" + enabledStatus + "|, and it actual is |" + element.Enabled.ToString().ToLower() + "| ", reportTypes);
                    }
                    else
                    {
                        reportsLibrary.WriteErrorMessageWithScreenshot(reportTypes, "fail", "For element" + fullElementName + " we expect Enabled status to be: |" + enabledStatus + "|, but actual status is |" + element.Enabled.ToString().ToLower() + "| ");
                    }
                }
                else
                {
                    reportsLibrary.WritePassResult("For element" + fullElementName + " we don't want to check Enabled status", reportTypes);
                }

                if (!(displayedStatus == string.Empty))
                {
                    if (element.Displayed.ToString().ToLower() == displayedStatus)
                    {
                        reportsLibrary.WritePassResult("For element" + fullElementName + " we expect Displayed status to be: |" + displayedStatus + "|, and it actual is |" + element.Displayed.ToString().ToLower() + "|", reportTypes);
                    }
                    else
                    {
                        reportsLibrary.WriteErrorMessageWithScreenshot(reportTypes, "fail", "For element" + fullElementName + " we expect Displayed status to be: |" + displayedStatus + "|, but actual status is |" + element.Displayed.ToString().ToLower() + "|");
                    }
                }
                else
                {
                    reportsLibrary.WritePassResult("For element" + fullElementName + " we don't want to check Displayed status", reportTypes);
                }
            }
            catch (Exception ex)
            {
                reportsLibrary.WriteErrorMessageWithScreenshot(reportTypes, "fatal", "Element " + fullElementName + " is missing. <br><b>ErrorMessage: </b><br>" + ex.Message);
                return;
            }
        }