Пример #1
0
        public override IElement GetElement(string fieldSelector, MatchConditions conditions)
        {
            var wElement = _browser.Element(Automation.Core.Find.BySelector(fieldSelector));
            ValidateElement(wElement, fieldSelector, conditions);

            return new Element(wElement);
        }
Пример #2
0
        /// <summary>
        /// Expects the specified selector and conditions match a specified number of fields.
        /// </summary>
        /// <param name="fieldSelector">The field selector.</param>
        /// <param name="conditions">The conditions.</param>
        public void Of(string fieldSelector, MatchConditions conditions)
        {
            if (CommandManager.EnableRemoteExecution)
            {
                CommandManager.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails()
                {
                    Name = "ExpectCount",
                    Arguments = new Dictionary<string, dynamic>()
                    {
                        { "selector", fieldSelector },
                        { "matchConditions", conditions.ToString() },
                        { "value", _count }
                    }
                });
            }
            else
            {
                CommandManager.CurrentActionBucket.Add(() =>
                {
                    var elements = Provider.GetElements(fieldSelector, conditions);

                    if (elements.Count() != _count)
                    {
                        Provider.TakeAssertExceptionScreenshot();
                        throw new AssertException("Count assertion failed. Expected there to be [{0}] elements matching [{1}]. Actual count is [{2}]", _count, fieldSelector, elements.Count());
                    }
                });
            }
        }
Пример #3
0
        /// <summary>
        /// Ins the specified field selector.
        /// </summary>
        /// <param name="fieldSelector">The field selector.</param>
        /// <param name="conditions">The conditions.</param>
        public void In(string fieldSelector, MatchConditions conditions)
        {
            _matchConditions = conditions;

            if (CommandManager.EnableRemoteExecution)
            {
                // args
                var arguments = new Dictionary<string, dynamic>();
                arguments.Add("selector", fieldSelector);
                if (_elementExpression != null) arguments.Add("expression", _elementExpression.ToExpressionString());

                CommandManager.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails()
                {
                    Name = "ExpectElement",
                    Arguments = arguments
                });
            }
            else
            {
                CommandManager.CurrentActionBucket.Add(() =>
                {
                    var element = Provider.GetElement(fieldSelector, conditions);

                    var compiledFunc = _elementExpression.Compile();
                    if (!compiledFunc(element))
                    {
                        Provider.TakeAssertExceptionScreenshot();
                        throw new AssertException("Element assertion failed. Expected element [{0}] to match expression [{1}].", fieldSelector, _elementExpression.ToExpressionString());
                    }
                });
            }
        }
Пример #4
0
        /// <summary>
        /// Expects the specified field has a specific class.
        /// </summary>
        /// <param name="fieldSelector">The field selector.</param>
        /// <param name="conditions">The conditions.</param>
        public void On(string fieldSelector, MatchConditions conditions)
        {
            if (CommandManager.EnableRemoteExecution)
            {
                CommandManager.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails()
                {
                    Name = "ExpectClass",
                    Arguments = new Dictionary<string, dynamic>()
                    {
                        { "selector", fieldSelector },
                        { "value", _value },
                        { "matchConditions", conditions.ToString() }
                    }
                });
            }
            else
            {
                CommandManager.CurrentActionBucket.Add(() =>
                {
                    var element = Provider.GetElement(fieldSelector, conditions);
                    string className = _value.Replace(".", "").Trim();
                    string elementClassName = element.GetAttributeValue("class").Trim();

                    if (elementClassName.Contains(' '))
                    {
                        string[] classes = elementClassName.Split(' ');
                        bool hasMatches = false;
                        foreach (var cssClass in classes)
                        {
                            var cssClassString = cssClass.Trim();
                            if (!string.IsNullOrEmpty(cssClassString))
                            {
                                if (cssClassString.Equals(className))
                                {
                                    hasMatches = true;
                                }
                            }
                        }

                        if (!hasMatches)
                        {
                            Provider.TakeAssertExceptionScreenshot();
                            throw new AssertException("Class name assertion failed. Expected element [{0}] to include a CSS class of [{1}].", fieldSelector, className);
                        }
                    }
                    else
                    {
                        if (!elementClassName.Equals(className))
                        {
                            Provider.TakeAssertExceptionScreenshot();
                            throw new AssertException("Class name assertion failed. Expected element [{0}] to include a CSS class of [{1}] but current CSS class is [{2}].", fieldSelector, className, elementClassName.PrettifyErrorValue());
                        }
                    }
                });
            }
        }
Пример #5
0
        public override IElement[] GetElements(string fieldSelector, MatchConditions conditions)
        {
            var elements = _browser.Elements.Filter(Automation.Core.Find.BySelector(fieldSelector));

            foreach (var element in elements)
            {
                ValidateElement(element, fieldSelector, conditions);
            }

            return elements.Select(e => new Element(e)).ToArray();
        }
Пример #6
0
 private void ValidateElement(IWebElement element, string fieldSelector, MatchConditions conditions)
 {
     if (conditions.HasFlag(MatchConditions.Visible))
     {
         if (!element.Displayed)
         {
             throw new MatchConditionException(fieldSelector, MatchConditions.Visible);
         }
     }
     else if (conditions.HasFlag(MatchConditions.Hidden))
     {
         if (element.Displayed)
         {
             throw new MatchConditionException(fieldSelector, MatchConditions.Hidden);
         }
     }
 }
        /// <summary>
        /// Creates a <see cref="ConfigurationSetting"/> if it doesn't exist or overrides an existing setting in the configuration store.
        /// </summary>
        /// <param name="setting"><see cref="ConfigurationSetting"/> to create.</param>
        /// <param name="onlyIfUnchanged"></param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
        public virtual async Task <Response <ConfigurationSetting> > SetAsync(ConfigurationSetting setting, bool onlyIfUnchanged = false, CancellationToken cancellationToken = default)
        {
            if (setting == null)
            {
                throw new ArgumentNullException($"{nameof(setting)}");
            }

            MatchConditions requestOptions = default;

            if (onlyIfUnchanged)
            {
                requestOptions         = new MatchConditions();
                requestOptions.IfMatch = setting.ETag;
            }

            return(await SetAsync(setting, requestOptions, cancellationToken).ConfigureAwait(false));
        }
        /// <summary>
        /// Creates a <see cref="ConfigurationSetting"/> if it doesn't exist or overrides an existing setting in the configuration store.
        /// </summary>
        /// <param name="setting"><see cref="ConfigurationSetting"/> to create.</param>
        /// <param name="onlyIfUnchanged"></param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
        public virtual Response <ConfigurationSetting> Set(ConfigurationSetting setting, bool onlyIfUnchanged = false, CancellationToken cancellationToken = default)
        {
            if (setting == null)
            {
                throw new ArgumentNullException($"{nameof(setting)}");
            }

            MatchConditions requestOptions = default;

            if (onlyIfUnchanged)
            {
                requestOptions = new MatchConditions();
                requestOptions.SetIfUnmodifiedCondition(setting.ETag);
            }

            return(Set(setting, requestOptions, cancellationToken));
        }
        public async Task GetWithRequestOptions()
        {
            // Get If-Match is not an expected use case, but enabled for completeness.

            var testSetting = s_testSetting.Clone();

            testSetting.ETag = new ETag("v1");

            var mockResponse = new MockResponse(200);

            mockResponse.SetContent(SerializationHelpers.Serialize(testSetting, SerializeSetting));

            var mockTransport           = new MockTransport(mockResponse);
            ConfigurationClient service = CreateTestService(mockTransport);

            var requestOptions = new MatchConditions {
                IfMatch = new ETag("v1")
            };

            ConfigurationSetting setting = await service.GetAsync(testSetting.Key, testSetting.Label, default, requestOptions);
Пример #10
0
 /// <summary>
 /// Hovers over the specified element selector that matches the conditions.
 /// </summary>
 /// <param name="elementSelector">The element selector.</param>
 /// <param name="conditions">The conditions.</param>
 public void Hover(string elementSelector, MatchConditions conditions)
 {
     if (this.EnableRemoteExecution)
     {
         this.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails()
         {
             Name      = "Hover",
             Arguments = new Dictionary <string, dynamic>()
             {
                 { "selector", elementSelector },
                 { "matchConditions", conditions.ToString() }
             }
         });
     }
     else
     {
         CurrentActionBucket.Add(() =>
         {
             var field = Provider.GetElement(elementSelector, conditions);
             field.Hover();
         });
     }
 }
        private Request CreateAddRequest(ConfigurationSetting setting)
        {
            Argument.AssertNotNull(setting, nameof(setting));
            Argument.AssertNotNullOrEmpty(setting.Key, $"{nameof(setting)}.{nameof(setting.Key)}");

            Request request = _pipeline.CreateRequest();

            ReadOnlyMemory <byte> content = Serialize(setting);

            request.Method = RequestMethod.Put;

            BuildUriForKvRoute(request.Uri, setting);

            MatchConditions requestOptions = new MatchConditions();

            requestOptions.IfNoneMatch = ETag.All;
            ConditionalRequestOptionsExtensions.ApplyHeaders(request, requestOptions);

            request.Headers.Add(s_mediaTypeKeyValueApplicationHeader);
            request.Headers.Add(HttpHeader.Common.JsonContentType);
            request.Content = RequestContent.Create(content);

            return(request);
        }
Пример #12
0
 /// <summary>
 /// Ins the specified conditions.
 /// </summary>
 /// <param name="conditions">The conditions.</param>
 /// <param name="fieldSelectors">The field selectors.</param>
 public void In(MatchConditions conditions, params string[] fieldSelectors)
 {
     _matchConditions = conditions;
     In(fieldSelectors);
 }
Пример #13
0
        /// <summary>
        /// Sets the value in the fields that match the selector generated by the Expression.
        /// </summary>
        /// <param name="fieldSelectorExpression">The field selector expression.</param>
        /// <param name="conditions">The conditions.</param>
        public void In(Expression <Func <string, string> > fieldSelectorExpression, MatchConditions conditions)
        {
            var fieldSelectorFunc = fieldSelectorExpression.Compile();

            In(fieldSelectorFunc(_value), conditions);
        }
Пример #14
0
 /// <summary>
 /// Hovers over the specified element selector that matches the conditions.
 /// </summary>
 /// <param name="elementSelector">The element selector.</param>
 /// <param name="conditions">The conditions.</param>
 public void Hover(string elementSelector, MatchConditions conditions)
 {
     if (this.EnableRemoteExecution)
     {
         this.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails()
         {
             Name = "Hover",
             Arguments = new Dictionary<string, dynamic>()
             {
                 { "selector", elementSelector },
                 { "matchConditions", conditions.ToString() }
             }
         });
     }
     else
     {
         CurrentActionBucket.Add(() =>
         {
             var field = Provider.GetElement(elementSelector, conditions);
             field.Hover();
         });
     }
 }
Пример #15
0
 private void ValidateElement(Automation.Core.Element element, string fieldSelector, MatchConditions conditions)
 {
     if (conditions.HasFlag(MatchConditions.Visible))
     {
         if (element.Style.Display.ToLower().Contains("none") || element.Style.GetAttributeValue("visibility") == "hidden")
         {
             throw new MatchConditionException(fieldSelector, MatchConditions.Visible);
         }
     }
     else if (conditions.HasFlag(MatchConditions.Hidden))
     {
         if (!element.Style.Display.ToLower().Contains("none") && !(element.Style.GetAttributeValue("visibility") == "visible"))
         {
             throw new MatchConditionException(fieldSelector, MatchConditions.Hidden);
         }
     }
 }
Пример #16
0
 /// <summary>
 /// Gets the select element matching the field selector and conditions.
 /// </summary>
 /// <param name="fieldSelector">The field selector.</param>
 /// <param name="conditions">The conditions.</param>
 /// <returns></returns>
 public abstract ISelectElement GetSelectElement(string fieldSelector, MatchConditions conditions);
 private void ValidateElement(Automation.Core.Element element, string fieldSelector, MatchConditions conditions)
 {
     if (conditions.HasFlag(MatchConditions.Visible))
     {
         if (element.Style.Display.ToLower().Contains("none") || element.Style.GetAttributeValue("visibility") == "hidden")
         {
             throw new MatchConditionException(fieldSelector, MatchConditions.Visible);
         }
     }
     else if (conditions.HasFlag(MatchConditions.Hidden))
     {
         if (!element.Style.Display.ToLower().Contains("none") && !(element.Style.GetAttributeValue("visibility") == "visible"))
         {
             throw new MatchConditionException(fieldSelector, MatchConditions.Hidden);
         }
     }
 }
 /// <summary>
 /// Gets the select element matching the field selector and conditions.
 /// </summary>
 /// <param name="fieldSelector">The field selector.</param>
 /// <param name="conditions">The conditions.</param>
 /// <returns></returns>
 public abstract ISelectElement GetSelectElement(string fieldSelector, MatchConditions conditions);
Пример #19
0
        /// <summary>
        /// Expects that the specified field's text matches.
        /// </summary>
        /// <param name="fieldSelector">The field selector.</param>
        /// <param name="conditions">The conditions.</param>
        public void In(string fieldSelector, MatchConditions conditions)
        {
            if (CommandManager.EnableRemoteExecution)
            {
                // args
                var arguments = new Dictionary<string, dynamic>();
                arguments.Add("selector", fieldSelector);
                arguments.Add("value", _expectedText);
                arguments.Add("matchConditions", conditions.ToString());
                if (_expectedTextExpression != null) arguments.Add("valueExpression", _expectedTextExpression.ToExpressionString());

                CommandManager.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails()
                {
                    Name = "ExpectText",
                    Arguments = arguments
                });
            }
            else
            {
                CommandManager.CurrentActionBucket.Add(() =>
                {
                    var element = Provider.GetElement(fieldSelector, conditions);
                    var elementText = element.GetText() ?? string.Empty;

                    if (element != null)
                    {
                        if (element.IsSelect())
                        {
                            var selectElement = Provider.GetSelectElement(fieldSelector, conditions);
                            if (_expectType == ExpectType.Single)
                            {
                                if (selectElement.IsMultiple)
                                {
                                    Provider.TakeAssertExceptionScreenshot();
                                    throw new AssertException("Single value assertion cannot be used on a SelectList that potentially has multiple values. Use Any or All instead.");
                                }

                                if (_expectedTextFunc != null)
                                {
                                    if (!_expectedTextFunc(selectElement.GetSelectedOptionText()))
                                    {
                                        Provider.TakeAssertExceptionScreenshot();
                                        throw new AssertException("SelectElement text assertion failed. Expected element [{0}] to match expression [{1}]. Actual text is [{2}].", fieldSelector, _expectedTextExpression.ToExpressionString(), selectElement.GetSelectedOptionText().PrettifyErrorValue());
                                    }
                                }
                                else
                                {
                                    if (!selectElement.GetSelectedOptionText().Equals(_expectedText, StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        Provider.TakeAssertExceptionScreenshot();
                                        throw new AssertException("SelectElement text assertion failed. Expected element [{0}] to have selected text of [{1}] but actual selected text is [{2}].", fieldSelector, _expectedText.PrettifyErrorValue(), selectElement.GetSelectedOptionText().PrettifyErrorValue());
                                    }
                                }
                            }
                            else
                            {
                                int textMatching = 0;
                                string[] selectedText = selectElement.GetSelectedOptionsText();

                                if (selectedText.Length > 0)
                                {
                                    foreach (string text in _expectedStrings)
                                    {
                                        bool isMatch = selectedText.Any(s => s.Equals(text, StringComparison.InvariantCultureIgnoreCase));
                                        if (isMatch) textMatching++;
                                    }

                                    if (_expectType == ExpectType.Any)
                                    {
                                        if (textMatching == 0)
                                        {
                                            Provider.TakeAssertExceptionScreenshot();
                                            throw new AssertException("SelectElement text assertion failed. Expected element [{0}] to have at least one option with text matching the following options: [{1}]", fieldSelector, string.Join(", ", _expectedStrings));
                                        }
                                    }
                                    else if (_expectType == ExpectType.All)
                                    {
                                        if (textMatching != _expectedStrings.Count())
                                        {
                                            Provider.TakeAssertExceptionScreenshot();
                                            throw new AssertException("SelectElement text assertion failed. Expected element [{0}] to include option text matching all the following options: [{1}]", fieldSelector, string.Join(", ", _expectedStrings));
                                        }
                                    }
                                }
                            }
                        }
                        else if (element.IsText())
                        {
                            var textElement = Provider.GetTextElement(fieldSelector, conditions);
                            var textElementText = textElement.GetText() ?? string.Empty;

                            if (_expectedTextFunc != null)
                            {
                                if (!_expectedTextFunc(textElementText))
                                {
                                    Provider.TakeAssertExceptionScreenshot();
                                    throw new AssertException("TextElement text assertion failed. Expected element [{0}] to match expression [{1}]. Actual value is [{2}].", fieldSelector, _expectedTextExpression.ToExpressionString(), textElementText.PrettifyErrorValue());
                                }
                            }
                            else
                            {
                                if (!textElementText.Equals(_expectedText ?? string.Empty, StringComparison.InvariantCultureIgnoreCase))
                                {
                                    Provider.TakeAssertExceptionScreenshot();
                                    throw new AssertException("TextElement text assertion failed. Expected element [{0}] to have a value of [{1}] but actual value is [{2}].", fieldSelector, _expectedText.PrettifyErrorValue(), textElementText.PrettifyErrorValue());
                                }
                            }
                        }
                        else
                        {
                            if (_expectedTextFunc != null)
                            {
                                if (!_expectedTextFunc(elementText))
                                {
                                    Provider.TakeAssertExceptionScreenshot();
                                    throw new AssertException("Value assertion failed. Expected element [{0}] to match expression [{1}]. Actual value is [{2}].", fieldSelector, _expectedTextExpression.ToExpressionString(), elementText.PrettifyErrorValue());
                                }
                            }
                            else
                            {
                                if (!elementText.Equals(_expectedText ?? string.Empty))
                                {
                                    Provider.TakeAssertExceptionScreenshot();
                                    throw new AssertException("Value assertion failed. Expected element [{0}] to have a value of [{1}] but actual value is [{2}].", fieldSelector, _expectedText.PrettifyErrorValue(), elementText.PrettifyErrorValue());
                                }
                            }
                        }
                    }
                });
            }
        }
Пример #20
0
        /// <summary>
        /// Selects values/text/indices from the specified field selector.
        /// </summary>
        /// <param name="fieldSelector">The field selector.</param>
        /// <param name="conditions">The conditions.</param>
        public void From(string fieldSelector, MatchConditions conditions)
        {
            if (CommandManager.EnableRemoteExecution)
            {
                // args
                var arguments = new Dictionary <string, dynamic>();
                arguments.Add("selector", fieldSelector);
                arguments.Add("selectMode", _selectMode.ToString());
                arguments.Add("matchConditions", conditions.ToString());
                if (_values != null)
                {
                    arguments.Add("values", _values);
                }
                if (_optionMatchingFunc != null)
                {
                    arguments.Add("valueExpression", _optionMatchingFunc.ToExpressionString());
                }
                if (_selectedIndices != null)
                {
                    arguments.Add("indices", _selectedIndices);
                }

                CommandManager.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails()
                {
                    Name      = "Select",
                    Arguments = arguments
                });
            }
            else
            {
                CommandManager.CurrentActionBucket.Add(() =>
                {
                    var field = Provider.GetSelectElement(fieldSelector, conditions);
                    field.ClearSelectedItems();

                    if (_selectMode == SelectMode.Value || _selectMode == SelectMode.Text)
                    {
                        if (_optionMatchingFunc == null)
                        {
                            if (_values.Length == 1)
                            {
                                field.SetValue(_values.First(), _selectMode);
                            }
                            else if (_values.Length > 1)
                            {
                                field.SetValues(_values, _selectMode);
                            }
                        }
                        else
                        {
                            field.SetValues(_optionMatchingFunc, _selectMode);
                        }
                    }
                    else if (_selectMode == SelectMode.Index)
                    {
                        if (_selectedIndices.Length == 1)
                        {
                            field.SetSelectedIndex(_selectedIndices.First());
                        }
                        else if (_selectedIndices.Length > 1)
                        {
                            field.SetSelectedIndices(_selectedIndices);
                        }
                    }
                });
            }
        }
Пример #21
0
        public override void Upload(string fileName, string fieldSelector, API.Point offset, MatchConditions conditions)
        {
            if (_browserType == BrowserType.InternetExplorer)
            {
                throw new FeatureNotImplementedException("SeleniumWebDriver+InternetExplorer File Upload");
            }

            var element = _driver.FindElement(BySizzle.CssSelector(fieldSelector));
            var t       = System.Threading.Tasks.Task.Factory.StartNew(() =>
            {
                // Dirty I know.. Need to guarantee the dialog opens before we start sending key events.
                int sleepTime = 0;
                switch (_browserType)
                {
                case BrowserType.Firefox:
                    sleepTime = 1000;
                    break;

                case BrowserType.Chrome:
                    sleepTime = 1500;
                    break;
                }

                Thread.Sleep(sleepTime);
                CommandManager.SendString(fileName + "~");
            }, System.Threading.Tasks.TaskCreationOptions.LongRunning);

            if (offset == null)
            {
                element.Click();
            }
            else
            {
                this.ClickWithin(fieldSelector, offset);
            }

            t.Wait();
        }
Пример #22
0
        /// <summary>
        /// Selects values/text/indices from the specified field selector.
        /// </summary>
        /// <param name="fieldSelector">The field selector.</param>
        /// <param name="conditions">The conditions.</param>
        public void From(string fieldSelector, MatchConditions conditions)
        {
            if (CommandManager.EnableRemoteExecution)
            {
                // args
                var arguments = new Dictionary<string, dynamic>();
                arguments.Add("selector", fieldSelector);
                arguments.Add("selectMode", _selectMode.ToString());
                arguments.Add("matchConditions", conditions.ToString());
                if (_values != null) arguments.Add("values", _values);
                if (_optionMatchingFunc != null) arguments.Add("valueExpression", _optionMatchingFunc.ToExpressionString());
                if (_selectedIndices != null) arguments.Add("indices", _selectedIndices);

                CommandManager.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails()
                {
                    Name = "Select",
                    Arguments = arguments
                });
            }
            else
            {
                CommandManager.CurrentActionBucket.Add(() =>
                {
                    var field = Provider.GetSelectElement(fieldSelector, conditions);
                    field.ClearSelectedItems();

                    if (_selectMode == SelectMode.Value || _selectMode == SelectMode.Text)
                    {
                        if (_optionMatchingFunc == null)
                        {
                            if (_values.Length == 1)
                            {
                                field.SetValue(_values.First(), _selectMode);
                            }
                            else if (_values.Length > 1)
                            {
                                field.SetValues(_values, _selectMode);
                            }
                        }
                        else
                        {
                            field.SetValues(_optionMatchingFunc, _selectMode);
                        }
                    }
                    else if (_selectMode == SelectMode.Index)
                    {
                        if (_selectedIndices.Length == 1)
                        {
                            field.SetSelectedIndex(_selectedIndices.First());
                        }
                        else if (_selectedIndices.Length > 1)
                        {
                            field.SetSelectedIndices(_selectedIndices);
                        }
                    }
                });
            }
        }
Пример #23
0
        /// <summary>
        /// Expects that the specified field's value matches.
        /// </summary>
        /// <param name="fieldSelector">The field selector.</param>
        /// <param name="conditions">The conditions.</param>
        public void In(string fieldSelector, MatchConditions conditions)
        {
            if (CommandManager.EnableRemoteExecution)
            {
                // args
                var arguments = new Dictionary<string, dynamic>();
                arguments.Add("selector", fieldSelector);
                arguments.Add("value", _value);
                arguments.Add("matchConditions", conditions.ToString());
                if (_valueExpression != null) arguments.Add("valueExpression", _valueExpression.ToExpressionString());

                CommandManager.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails()
                {
                    Name = "ExpectText",
                    Arguments = arguments
                });
            }
            else
            {
                CommandManager.CurrentActionBucket.Add(() =>
                {
                    var element = Provider.GetElement(fieldSelector, conditions);
                    var elementValue = element.GetValue() ?? string.Empty;

                    if (element != null)
                    {
                        if (_value == null && element.GetText() != null && elementValue != string.Empty)
                        {
                            Provider.TakeAssertExceptionScreenshot();
                            throw new AssertException("Null value assertion failed. Element [{0}] has a value of [{1}].", fieldSelector, element.GetText().PrettifyErrorValue());
                        }

                        if (!element.IsSelect() && (_expectType == ExpectType.Any || _expectType == ExpectType.All))
                        {
                            Provider.TakeAssertExceptionScreenshot();
                            throw new AssertException("Value assertion of types Any and All can only be used on SelectList elements.");
                        }
                        else if (element.IsSelect())
                        {
                            var selectElement = Provider.GetSelectElement(fieldSelector, conditions);
                            if (_expectType == ExpectType.Single)
                            {
                                if (selectElement.IsMultiple)
                                {
                                    Provider.TakeAssertExceptionScreenshot();
                                    throw new AssertException("Single value assertion cannot be used on a SelectList that potentially has multiple values. Use Any or All instead.");
                                }

                                if (_valueFunc != null)
                                {
                                    if (!_valueFunc(selectElement.GetValue()))
                                    {
                                        Provider.TakeAssertExceptionScreenshot();
                                        throw new AssertException("SelectElement value assertion failed. Expected element [{0}] to match expression [{1}]. Actual value is [{2}].", fieldSelector, _valueExpression.ToExpressionString(), selectElement.GetValue().PrettifyErrorValue());
                                    }
                                }
                                else
                                {
                                    if (!selectElement.GetValue().Equals(_value, StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        Provider.TakeAssertExceptionScreenshot();
                                        throw new AssertException("SelectElement value assertion failed. Expected element [{0}] to have a selected value of [{1}] but actual selected value is [{2}].", fieldSelector, _value.PrettifyErrorValue(), selectElement.GetValue().PrettifyErrorValue());
                                    }
                                }
                            }
                            else
                            {
                                int valuesMatching = 0;
                                string[] selectedValues = selectElement.GetValues();

                                if (selectedValues.Length > 0)
                                {
                                    foreach (var selectedValue in selectedValues)
                                    {
                                        foreach (var value in _values)
                                        {
                                            if ((_valueFunc != null && !_valueFunc(selectedValue)) ||
                                                (selectedValue.Equals(value, StringComparison.InvariantCultureIgnoreCase)))
                                            {
                                                valuesMatching++;
                                            }
                                        }
                                    }
                                }

                                if (_expectType == ExpectType.Any)
                                {
                                    if (valuesMatching == 0)
                                    {
                                        Provider.TakeAssertExceptionScreenshot();
                                        throw new AssertException("SelectElement value assertion failed. Expected element [{0}] to have at least one of the following values: [{1}]", fieldSelector, string.Join(", ", _values));
                                    }
                                }
                                else if (_expectType == ExpectType.All)
                                {
                                    if (valuesMatching < _values.Count())
                                    {
                                        Provider.TakeAssertExceptionScreenshot();
                                        throw new AssertException("SelectElement value assertion failed. Expected element [{0}] to include all of the following values: [{1}]", fieldSelector, string.Join(", ", _values));
                                    }
                                }
                            }
                        }
                        else if (element.IsText())
                        {
                            var textElement = Provider.GetTextElement(fieldSelector, conditions);
                            var textElementValue = textElement.GetValue() ?? string.Empty;
                            if (_valueFunc != null)
                            {
                                if (!_valueFunc(textElementValue))
                                {
                                    Provider.TakeAssertExceptionScreenshot();
                                    throw new AssertException("TextElement value assertion failed. Expected element [{0}] to match expression [{1}]. Actual value is [{2}].", fieldSelector, _valueExpression.ToExpressionString(), textElementValue.PrettifyErrorValue());
                                }
                            }
                            else
                            {
                                if (!textElementValue.Equals(_value ?? string.Empty, StringComparison.InvariantCultureIgnoreCase))
                                {
                                    Provider.TakeAssertExceptionScreenshot();
                                    throw new AssertException("TextElement value assertion failed. Expected element [{0}] to have a value of [{1}] but actual value is [{2}].", fieldSelector, _value.PrettifyErrorValue(), textElementValue.PrettifyErrorValue());
                                }
                            }
                        }
                        else
                        {
                            if (_valueFunc != null)
                            {
                                if (!_valueFunc(elementValue))
                                {
                                    Provider.TakeAssertExceptionScreenshot();
                                    throw new AssertException("Value assertion failed. Expected element [{0}] to match expression [{1}]. Actual value is [{2}].", fieldSelector, _valueExpression.ToExpressionString(), elementValue.PrettifyErrorValue());
                                }
                            }
                            else
                            {
                                if (!elementValue.Equals(_value ?? string.Empty))
                                {
                                    Provider.TakeAssertExceptionScreenshot();
                                    throw new AssertException("Value assertion failed. Expected element [{0}] to have a value of [{1}] but actual value is [{2}].", fieldSelector, _value.PrettifyErrorValue(), elementValue.PrettifyErrorValue());
                                }
                            }
                        }
                    }
                });
            }
        }
Пример #24
0
        /// <summary>
        /// Expects that the specified field's text matches.
        /// </summary>
        /// <param name="fieldSelector">The field selector.</param>
        /// <param name="conditions">The conditions.</param>
        public void In(string fieldSelector, MatchConditions conditions)
        {
            if (CommandManager.EnableRemoteExecution)
            {
                // args
                var arguments = new Dictionary <string, dynamic>();
                arguments.Add("selector", fieldSelector);
                arguments.Add("value", _expectedText);
                arguments.Add("matchConditions", conditions.ToString());
                if (_expectedTextExpression != null)
                {
                    arguments.Add("valueExpression", _expectedTextExpression.ToExpressionString());
                }

                CommandManager.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails()
                {
                    Name      = "ExpectText",
                    Arguments = arguments
                });
            }
            else
            {
                CommandManager.CurrentActionBucket.Add(() =>
                {
                    var element     = Provider.GetElement(fieldSelector, conditions);
                    var elementText = element.GetText() ?? string.Empty;

                    if (element != null)
                    {
                        if (element.IsSelect())
                        {
                            var selectElement = Provider.GetSelectElement(fieldSelector, conditions);
                            if (_expectType == ExpectType.Single)
                            {
                                if (selectElement.IsMultiple)
                                {
                                    Provider.TakeAssertExceptionScreenshot();
                                    throw new AssertException("Single value assertion cannot be used on a SelectList that potentially has multiple values. Use Any or All instead.");
                                }

                                if (_expectedTextFunc != null)
                                {
                                    if (!_expectedTextFunc(selectElement.GetSelectedOptionText()))
                                    {
                                        Provider.TakeAssertExceptionScreenshot();
                                        throw new AssertException("SelectElement text assertion failed. Expected element [{0}] to match expression [{1}]. Actual text is [{2}].", fieldSelector, _expectedTextExpression.ToExpressionString(), selectElement.GetSelectedOptionText().PrettifyErrorValue());
                                    }
                                }
                                else
                                {
                                    if (!selectElement.GetSelectedOptionText().Equals(_expectedText, StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        Provider.TakeAssertExceptionScreenshot();
                                        throw new AssertException("SelectElement text assertion failed. Expected element [{0}] to have selected text of [{1}] but actual selected text is [{2}].", fieldSelector, _expectedText.PrettifyErrorValue(), selectElement.GetSelectedOptionText().PrettifyErrorValue());
                                    }
                                }
                            }
                            else
                            {
                                int textMatching      = 0;
                                string[] selectedText = selectElement.GetSelectedOptionsText();

                                if (selectedText.Length > 0)
                                {
                                    foreach (string text in _expectedStrings)
                                    {
                                        bool isMatch = selectedText.Any(s => s.Equals(text, StringComparison.InvariantCultureIgnoreCase));
                                        if (isMatch)
                                        {
                                            textMatching++;
                                        }
                                    }

                                    if (_expectType == ExpectType.Any)
                                    {
                                        if (textMatching == 0)
                                        {
                                            Provider.TakeAssertExceptionScreenshot();
                                            throw new AssertException("SelectElement text assertion failed. Expected element [{0}] to have at least one option with text matching the following options: [{1}]", fieldSelector, string.Join(", ", _expectedStrings));
                                        }
                                    }
                                    else if (_expectType == ExpectType.All)
                                    {
                                        if (textMatching != _expectedStrings.Count())
                                        {
                                            Provider.TakeAssertExceptionScreenshot();
                                            throw new AssertException("SelectElement text assertion failed. Expected element [{0}] to include option text matching all the following options: [{1}]", fieldSelector, string.Join(", ", _expectedStrings));
                                        }
                                    }
                                }
                            }
                        }
                        else if (element.IsText())
                        {
                            var textElement     = Provider.GetTextElement(fieldSelector, conditions);
                            var textElementText = textElement.GetText() ?? string.Empty;

                            if (_expectedTextFunc != null)
                            {
                                if (!_expectedTextFunc(textElementText))
                                {
                                    Provider.TakeAssertExceptionScreenshot();
                                    throw new AssertException("TextElement text assertion failed. Expected element [{0}] to match expression [{1}]. Actual value is [{2}].", fieldSelector, _expectedTextExpression.ToExpressionString(), textElementText.PrettifyErrorValue());
                                }
                            }
                            else
                            {
                                if (!textElementText.Equals(_expectedText ?? string.Empty, StringComparison.InvariantCultureIgnoreCase))
                                {
                                    Provider.TakeAssertExceptionScreenshot();
                                    throw new AssertException("TextElement text assertion failed. Expected element [{0}] to have a value of [{1}] but actual value is [{2}].", fieldSelector, _expectedText.PrettifyErrorValue(), textElementText.PrettifyErrorValue());
                                }
                            }
                        }
                        else
                        {
                            if (_expectedTextFunc != null)
                            {
                                if (!_expectedTextFunc(elementText))
                                {
                                    Provider.TakeAssertExceptionScreenshot();
                                    throw new AssertException("Value assertion failed. Expected element [{0}] to match expression [{1}]. Actual value is [{2}].", fieldSelector, _expectedTextExpression.ToExpressionString(), elementText.PrettifyErrorValue());
                                }
                            }
                            else
                            {
                                if (!elementText.Equals(_expectedText ?? string.Empty))
                                {
                                    Provider.TakeAssertExceptionScreenshot();
                                    throw new AssertException("Value assertion failed. Expected element [{0}] to have a value of [{1}] but actual value is [{2}].", fieldSelector, _expectedText.PrettifyErrorValue(), elementText.PrettifyErrorValue());
                                }
                            }
                        }
                    }
                });
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MatchConditionException"/> class.
 /// </summary>
 /// <param name="fieldSelector">The field selector.</param>
 /// <param name="failedCondition">The failed condition.</param>
 public MatchConditionException(string fieldSelector, MatchConditions failedCondition)
     : base("Match condition not met. Element [{0}] does not meet the specified condition: [{1}].", fieldSelector, failedCondition)
 {
 }
        private void DataJoinShapeFile()
        {
            var args = new UpdatingTaskProgressEventArgs(TaskState.Updating);
            ShapeFileFeatureSource currentSource = ShapeFileFeatureSource;

            if (!currentSource.IsOpen)
            {
                currentSource.Open();
            }
            var index = 0;
            var count = currentSource.GetAllFeatures(ReturningColumnsType.AllColumns).Count;

            Collection <DbfColumn> includeColumns = new Collection <DbfColumn>();

            RemoveUnduplicateColumn(IncludedColumnsList);

            foreach (var column in IncludedColumnsList)
            {
                DbfColumnType tmpDbfColumnType = DbfColumnType.Character;
                if (Enum.TryParse(column.TypeName, out tmpDbfColumnType))
                {
                    DbfColumn dbfColumn = new DbfColumn(column.ColumnName, tmpDbfColumnType, column.MaxLength, 0);
                    includeColumns.Add(dbfColumn);
                }
            }

            ShapeFileType shapeFileType = GetShapeFileType(currentSource.GetAllFeatures(ReturningColumnsType.AllColumns).FirstOrDefault());
            var           projectionWkt = Proj4Projection.ConvertProj4ToPrj(DisplayProjectionParameters);
            var           dataTable     = DataJoinAdapter.ReadDataToDataGrid(CsvFilePath, Delimiter);
            var           featureRows   = dataTable.Rows;

            var helper = new ShapeFileHelper(shapeFileType, OutputPathFileName, includeColumns, projectionWkt);

            helper.ForEachFeatures(currentSource, (f, currentProgress, upperBound, percentage) =>
            {
                try
                {
                    bool canceled = false;
                    if (f.GetWellKnownBinary() != null)
                    {
                        index++;
                        try
                        {
                            var matchedDataRow = featureRows.Cast <DataRow>().FirstOrDefault(r => MatchConditions.All(tmpCondition => f.ColumnValues[tmpCondition.SelectedLayerColumn.ColumnName]
                                                                                                                      == r[tmpCondition.SelectedDelimitedColumn.ColumnName].ToString()));

                            if (matchedDataRow != null)
                            {
                                SetFeatureColumnValues(f, matchedDataRow, IncludedColumnsList, InvalidColumns);
                                helper.Add(f);
                            }
                            else if (IsIncludeAllFeatures)
                            {
                                helper.Add(f);
                            }

                            if (UpdateProgress(OnUpdatingProgress, index, count))
                            {
                                canceled = true;
                            }
                        }
                        catch (Exception ex)
                        {
                            var errorEventArgs   = new UpdatingTaskProgressEventArgs(TaskState.Error);
                            errorEventArgs.Error = new ExceptionInfo(string.Format(CultureInfo.InvariantCulture, "Feature id: {0}, {1}"
                                                                                   , f.Id, ex.Message)
                                                                     , ex.StackTrace
                                                                     , ex.Source);
                            GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex));
                            errorEventArgs.Message = f.Id;
                            OnUpdatingProgress(errorEventArgs);
                        }
                    }

                    args            = new UpdatingTaskProgressEventArgs(TaskState.Updating, percentage);
                    args.Current    = currentProgress;
                    args.UpperBound = upperBound;
                    OnUpdatingProgress(args);

                    canceled = args.TaskState == TaskState.Canceled;
                    return(canceled);
                }
                catch
                {
                    return(false);
                }
            });

            helper.Commit();

            SavePrjFile(OutputPathFileName, DisplayProjectionParameters);
        }
Пример #27
0
 /// <summary>
 /// Uploads the specified file name.
 /// </summary>
 /// <param name="fileName">Name of the file.</param>
 /// <param name="fieldSelector">The field selector.</param>
 /// <param name="offset">The offset.</param>
 /// <param name="conditions">The conditions.</param>
 protected void Upload(string fileName, string fieldSelector, API.Point offset, MatchConditions conditions)
 {
     if (this.EnableRemoteExecution)
     {
         this.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails()
         {
             Name = "Upload",
             Arguments = new Dictionary<string, dynamic>()
             {
                 { "selector", fieldSelector },
                 { "fileName", fileName },
                 { "offset", string.Format("{0},{1}", offset.X, offset.Y) },
                 { "matchConditions", conditions.ToString() }
             }
         });
     }
     else
     {
         CurrentActionBucket.Add(() =>
         {
             Provider.Upload(fileName, fieldSelector, offset, conditions);
         });
     }
 }
 public override void Upload(string fileName, string fieldSelector, API.Point offset, MatchConditions conditions)
 {
     if (offset == null)
     {
         var handler = new Automation.Core.DialogHandlers.FileUploadDialogHandler(fileName);
         using (new Automation.Core.DialogHandlers.UseDialogOnce(_browser.DialogWatcher, handler))
         {
             IElement element = GetElement(fieldSelector, conditions);
             element.Click(ClickMode.Default);
         }
     }
     else
     {
         this.ClickWithin(fieldSelector, offset);
         this.Wait(TimeSpan.FromMilliseconds(1000));
         CommandManager.SendString(fileName + "~");
     }
 }
Пример #29
0
 /// <summary>
 /// Focuses the specified element selector.
 /// </summary>
 /// <param name="elementSelector">The element selector.</param>
 /// <param name="conditions">The conditions.</param>
 public void Focus(string elementSelector, MatchConditions conditions)
 {
     CurrentActionBucket.Add(() =>
     {
         var field = Provider.GetElement(elementSelector, conditions);
         field.Focus();
     });
 }
 /// <summary>
 /// Uploads the specified file name with the field specified.
 /// </summary>
 /// <param name="fileName">Name of the file.</param>
 /// <param name="fieldSelector">The field selector.</param>
 /// <param name="conditions">The conditions.</param>
 public abstract void Upload(string fileName, string fieldSelector, API.Point offset, MatchConditions conditions);
Пример #31
0
 /// <summary>
 /// Uploads the specified file name with the field specified.
 /// </summary>
 /// <param name="fileName">Name of the file.</param>
 /// <param name="fieldSelector">The field selector.</param>
 /// <param name="conditions">The conditions.</param>
 public abstract void Upload(string fileName, string fieldSelector, API.Point offset, MatchConditions conditions);
 /// <summary>
 /// Gets the elements matching the field selector and conditions.
 /// </summary>
 /// <param name="fieldSelector">The field selector.</param>
 /// <param name="conditions">The conditions.</param>
 /// <returns></returns>
 public abstract IElement[] GetElements(string fieldSelector, MatchConditions conditions);
Пример #33
0
 public override void Upload(string fileName, string fieldSelector, API.Point offset, MatchConditions conditions)
 {
     if (offset == null)
     {
         var handler = new Automation.Core.DialogHandlers.FileUploadDialogHandler(fileName);
         using (new Automation.Core.DialogHandlers.UseDialogOnce(_browser.DialogWatcher, handler))
         {
             IElement element = GetElement(fieldSelector, conditions);
             element.Click(ClickMode.Default);
         }
     }
     else
     {
         this.ClickWithin(fieldSelector, offset);
         this.Wait(TimeSpan.FromMilliseconds(1000));
         CommandManager.SendString(fileName + "~");
     }
 }
Пример #34
0
 /// <summary>
 /// Ins the specified conditions.
 /// </summary>
 /// <param name="conditions">The conditions.</param>
 /// <param name="fieldSelectors">The field selectors.</param>
 public void In(MatchConditions conditions, params string[] fieldSelectors)
 {
     _matchConditions = conditions;
     In(fieldSelectors);
 }
        /// <summary>
        /// Creates a <see cref="ConfigurationSetting"/> if it doesn't exist or overrides an existing setting in the configuration store.
        /// </summary>
        /// <param name="setting"><see cref="ConfigurationSetting"/> to create.</param>
        /// <param name="requestOptions"></param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
        public virtual async Task <Response <ConfigurationSetting> > SetAsync(ConfigurationSetting setting, MatchConditions requestOptions, CancellationToken cancellationToken = default)
        {
            using DiagnosticScope scope = _clientDiagnostics.CreateScope("Azure.Data.AppConfiguration.ConfigurationClient.Set");
            scope.AddAttribute("key", setting?.Key);
            scope.Start();

            try
            {
                using Request request = CreateSetRequest(setting, requestOptions);
                Response response = await _pipeline.SendRequestAsync(request, cancellationToken).ConfigureAwait(false);

                return(response.Status switch
                {
                    200 => await CreateResponseAsync(response, cancellationToken).ConfigureAwait(false),
                    409 => throw await response.CreateRequestFailedExceptionAsync("The setting is read only").ConfigureAwait(false),

                    // Throws on 412 if resource was modified.
                    _ => throw await response.CreateRequestFailedExceptionAsync().ConfigureAwait(false),
                });
            }
Пример #36
0
 /// <summary>
 /// Gets the elements matching the field selector and conditions.
 /// </summary>
 /// <param name="fieldSelector">The field selector.</param>
 /// <param name="conditions">The conditions.</param>
 /// <returns></returns>
 public abstract IElement[] GetElements(string fieldSelector, MatchConditions conditions);
Пример #37
0
 /// <summary>
 /// Uploads the specified file name.
 /// </summary>
 /// <param name="fileName">Name of the file.</param>
 /// <param name="fieldSelector">The field selector.</param>
 /// <param name="offset">The offset.</param>
 /// <param name="conditions">The conditions.</param>
 protected void Upload(string fileName, string fieldSelector, API.Point offset, MatchConditions conditions)
 {
     if (this.EnableRemoteExecution)
     {
         this.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails()
         {
             Name      = "Upload",
             Arguments = new Dictionary <string, dynamic>()
             {
                 { "selector", fieldSelector },
                 { "fileName", fileName },
                 { "offset", string.Format("{0},{1}", offset.X, offset.Y) },
                 { "matchConditions", conditions.ToString() }
             }
         });
     }
     else
     {
         CurrentActionBucket.Add(() =>
         {
             Provider.Upload(fileName, fieldSelector, offset, conditions);
         });
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MatchConditionException"/> class.
 /// </summary>
 /// <param name="fieldSelector">The field selector.</param>
 /// <param name="failedCondition">The failed condition.</param>
 public MatchConditionException(string fieldSelector, MatchConditions failedCondition)
     : base("Match condition not met. Element [{0}] does not meet the specified condition: [{1}].", fieldSelector, failedCondition)
 {
 }
Пример #39
0
        /// <summary>
        /// Expects that the specified field's value matches.
        /// </summary>
        /// <param name="fieldSelector">The field selector.</param>
        /// <param name="conditions">The conditions.</param>
        public void In(string fieldSelector, MatchConditions conditions)
        {
            if (CommandManager.EnableRemoteExecution)
            {
                // args
                var arguments = new Dictionary <string, dynamic>();
                arguments.Add("selector", fieldSelector);
                arguments.Add("value", _value);
                arguments.Add("matchConditions", conditions.ToString());
                if (_valueExpression != null)
                {
                    arguments.Add("valueExpression", _valueExpression.ToExpressionString());
                }

                CommandManager.RemoteCommands.Add(new RemoteCommands.RemoteCommandDetails()
                {
                    Name      = "ExpectText",
                    Arguments = arguments
                });
            }
            else
            {
                CommandManager.CurrentActionBucket.Add(() =>
                {
                    var element      = Provider.GetElement(fieldSelector, conditions);
                    var elementValue = element.GetValue() ?? string.Empty;

                    if (element != null)
                    {
                        if (_value == null && element.GetText() != null && elementValue != string.Empty)
                        {
                            Provider.TakeAssertExceptionScreenshot();
                            throw new AssertException("Null value assertion failed. Element [{0}] has a value of [{1}].", fieldSelector, element.GetText().PrettifyErrorValue());
                        }

                        if (!element.IsSelect() && (_expectType == ExpectType.Any || _expectType == ExpectType.All))
                        {
                            Provider.TakeAssertExceptionScreenshot();
                            throw new AssertException("Value assertion of types Any and All can only be used on SelectList elements.");
                        }
                        else if (element.IsSelect())
                        {
                            var selectElement = Provider.GetSelectElement(fieldSelector, conditions);
                            if (_expectType == ExpectType.Single)
                            {
                                if (selectElement.IsMultiple)
                                {
                                    Provider.TakeAssertExceptionScreenshot();
                                    throw new AssertException("Single value assertion cannot be used on a SelectList that potentially has multiple values. Use Any or All instead.");
                                }

                                if (_valueFunc != null)
                                {
                                    if (!_valueFunc(selectElement.GetValue()))
                                    {
                                        Provider.TakeAssertExceptionScreenshot();
                                        throw new AssertException("SelectElement value assertion failed. Expected element [{0}] to match expression [{1}]. Actual value is [{2}].", fieldSelector, _valueExpression.ToExpressionString(), selectElement.GetValue().PrettifyErrorValue());
                                    }
                                }
                                else
                                {
                                    if (!selectElement.GetValue().Equals(_value, StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        Provider.TakeAssertExceptionScreenshot();
                                        throw new AssertException("SelectElement value assertion failed. Expected element [{0}] to have a selected value of [{1}] but actual selected value is [{2}].", fieldSelector, _value.PrettifyErrorValue(), selectElement.GetValue().PrettifyErrorValue());
                                    }
                                }
                            }
                            else
                            {
                                int valuesMatching      = 0;
                                string[] selectedValues = selectElement.GetValues();

                                if (selectedValues.Length > 0)
                                {
                                    foreach (var selectedValue in selectedValues)
                                    {
                                        foreach (var value in _values)
                                        {
                                            if ((_valueFunc != null && !_valueFunc(selectedValue)) ||
                                                (selectedValue.Equals(value, StringComparison.InvariantCultureIgnoreCase)))
                                            {
                                                valuesMatching++;
                                            }
                                        }
                                    }
                                }

                                if (_expectType == ExpectType.Any)
                                {
                                    if (valuesMatching == 0)
                                    {
                                        Provider.TakeAssertExceptionScreenshot();
                                        throw new AssertException("SelectElement value assertion failed. Expected element [{0}] to have at least one of the following values: [{1}]", fieldSelector, string.Join(", ", _values));
                                    }
                                }
                                else if (_expectType == ExpectType.All)
                                {
                                    if (valuesMatching < _values.Count())
                                    {
                                        Provider.TakeAssertExceptionScreenshot();
                                        throw new AssertException("SelectElement value assertion failed. Expected element [{0}] to include all of the following values: [{1}]", fieldSelector, string.Join(", ", _values));
                                    }
                                }
                            }
                        }
                        else if (element.IsText())
                        {
                            var textElement      = Provider.GetTextElement(fieldSelector, conditions);
                            var textElementValue = textElement.GetValue() ?? string.Empty;
                            if (_valueFunc != null)
                            {
                                if (!_valueFunc(textElementValue))
                                {
                                    Provider.TakeAssertExceptionScreenshot();
                                    throw new AssertException("TextElement value assertion failed. Expected element [{0}] to match expression [{1}]. Actual value is [{2}].", fieldSelector, _valueExpression.ToExpressionString(), textElementValue.PrettifyErrorValue());
                                }
                            }
                            else
                            {
                                if (!textElementValue.Equals(_value ?? string.Empty, StringComparison.InvariantCultureIgnoreCase))
                                {
                                    Provider.TakeAssertExceptionScreenshot();
                                    throw new AssertException("TextElement value assertion failed. Expected element [{0}] to have a value of [{1}] but actual value is [{2}].", fieldSelector, _value.PrettifyErrorValue(), textElementValue.PrettifyErrorValue());
                                }
                            }
                        }
                        else
                        {
                            if (_valueFunc != null)
                            {
                                if (!_valueFunc(elementValue))
                                {
                                    Provider.TakeAssertExceptionScreenshot();
                                    throw new AssertException("Value assertion failed. Expected element [{0}] to match expression [{1}]. Actual value is [{2}].", fieldSelector, _valueExpression.ToExpressionString(), elementValue.PrettifyErrorValue());
                                }
                            }
                            else
                            {
                                if (!elementValue.Equals(_value ?? string.Empty))
                                {
                                    Provider.TakeAssertExceptionScreenshot();
                                    throw new AssertException("Value assertion failed. Expected element [{0}] to have a value of [{1}] but actual value is [{2}].", fieldSelector, _value.PrettifyErrorValue(), elementValue.PrettifyErrorValue());
                                }
                            }
                        }
                    }
                });
            }
        }