Esempio n. 1
0
        private Dictionary <string, int> GetColumnsMap()
        {
            var result = new Dictionary <string, int>();
            var header = WebElement.TryFindStableElement(By.TagName("thead"));

            if (header == null)
            {
                return(result);
            }

            var retryResult = RetryHelper.RetryWithExceptions <StaleElementReferenceException>(3, () =>
            {
                result.Clear();
                var columns = header.FindElements(By.TagName("th"));
                for (int i = 0; i < columns.Count; i++)
                {
                    var columnHeader = columns[i].Text ?? string.Empty;
                    if (string.IsNullOrWhiteSpace(columnHeader) == false && result.ContainsKey(columnHeader) == false)
                    {
                        result.Add(columnHeader, i);
                    }
                }
                return(true);
            });

            if (retryResult.Success == false)
            {
                throw new ApplicationException("Unable to collect table headers", retryResult.LastException);
            }
            return(result);
        }
Esempio n. 2
0
        private void SetFieldValue(IWebFormFieldLocator fieldLocator, string value, AfterFieldValueSet?customAction)
        {
            var fieldWrapper = CreateFieldWrapper(fieldLocator);

            var retryResult = RetryHelper.RetryWithExceptions(numberOfSetRetries, () =>
            {
                fieldWrapper.SetValue(value);
                if (fieldWrapper.FieldAdapter.SupportSetRetry())
                {
                    return(fieldWrapper.GetValue() == value);
                }
                return(true);
            });

            if (retryResult.Success == false)
            {
                throw new UnableToSetFieldValueException(fieldLocator.GetFieldDescription(), value, retryResult.LastException);
            }

            InvokeAfterFieldValueSet(fieldWrapper.FieldElement, customAction ?? afterFieldValueSet);
        }