public IWebElement ColumnHeader(string colName)
        {
            var entityDetailsSection = EntityDetailUtils.GetEntityDetailsSection(_entityName, _contextConfiguration);
            var columnHeader         = entityDetailsSection.GetHeaderTile(colName);

            return(columnHeader);
        }
        public void ThenIValidateEachEntityHasEntityAssociations(string referenceOppositeName, int numAssociations, string targetEntityName, string association)
        {
            if (targetEntityName is null)
            {
                throw new ArgumentNullException(nameof(targetEntityName));
            }

            // form a list of expected guids to compare with the ones that are read off the page
            ICollection <Guid> expectedGuids = new List <Guid>();
            ICollection <Guid> searchGuids   = new List <Guid>();

            if (association == _initialAssociation)
            {
                _targetEntities.ForEach(x => searchGuids.Add(x.Id));
                _sourceEntities.ForEach(x => expectedGuids.Add(x.Id));
            }
            else
            {
                _targetEntities.ForEach(x => expectedGuids.Add(x.Id));
                _sourceEntities.ForEach(x => searchGuids.Add(x.Id));
            }

            // Navigate to entity page
            var page = new GenericEntityPage(referenceOppositeName, _contextConfiguration);

            page.Navigate();

            foreach (var searchGuid in searchGuids)
            {
                // Search for entity using GUID
                page.SearchInput.ClickWithWait(_driverWait);
                page.SearchInput.SendKeys(searchGuid.ToString());
                page.SearchButton.Click();
                _driverWait.Until(_ => page.TotalEntities() == 1);
                page.GetAllEntites().FirstOrDefault()?.EditItem();

                // Get the guids from the page
                var entityDetailsSection = EntityDetailUtils.GetEntityDetailsSection(referenceOppositeName, _contextConfiguration);
                var associations         = entityDetailsSection.GetAssociation(association.Replace(" ", "").ToLower());

                // Assert the guids on the page match the expected guids
                foreach (var guid in expectedGuids)
                {
                    Assert.Contains(guid, associations);
                }
                Assert.Equal(numAssociations, associations.Count);
                new GenericEntityEditPage(_contextConfiguration).Cancel();
            }
        }
Beispiel #3
0
        public void IVerifyAWarningForLiveValidators(ValidatorType validator, string attribute, ValidatorActionType validatorType)
        {
            var factory                  = new EntityFactory(_entityName);
            var entity                   = factory.Construct();
            var invalidAttribute         = entity.GetInvalidAttribute(attribute, validator.ToString().ToLower().Capitalize());
            var createPageDetailsSection = EntityDetailUtils.GetEntityDetailsSection(_entityName, _contextConfiguration);

            createPageDetailsSection.SetInputElement(attribute, invalidAttribute);

            switch (validatorType)
            {
            case ValidatorActionType.ON_SUBMIT:
                _createPage.SubmitButton.Click();
                break;

            case ValidatorActionType.LIVE:
                createPageDetailsSection.GetInputElement(attribute).SendKeys(Keys.Tab);
                break;
            }

            var errors = createPageDetailsSection.GetErrorMessagesForAttribute(attribute);

            switch (validator)
            {
            case ValidatorType.LENGTH:
                //(int min, int max) attributeLengthMinMax = entity.GetLengthValidatorMinMax(attribute);
                //Assert.Contains($"The length of this field is not less than {attributeLengthMinMax.max}. Actual Length: {attributeLengthMinMax.max + 1}", errors);
                (_, int max) = entity.GetLengthValidatorMinMax(attribute);
                Assert.Contains($"The length of this field is not less than {max}. Actual Length: {max + 1}", errors);
                break;

            case ValidatorType.EMAIL:
                Assert.Contains($"The value is not a valid email", errors);
                break;

            case ValidatorType.NUMERIC:
                Assert.Contains("You can only use numbers in this field", errors);
                break;

            case ValidatorType.REQUIRED:
                Assert.Contains("This field is required", errors);
                break;

            default:
                throw new Exception($"{validator} is not a valid validator");
            }
        }
 public GenericEntityEditPage(string entityName, ContextConfiguration contextConfiguration) : base(contextConfiguration)
 {
     Url            = baseUrl + "/admin/" + entityName + "/edit";
     _entityName    = entityName;
     detailsSection = EntityDetailUtils.GetEntityDetailsSection(entityName, contextConfiguration);
 }