public virtual ComponentGeneratorOutput GenerateComponentClass(string selector, ElementSelectorData[] elements)
        {
            string className = SelectorUtils.GetClassOrPropNameFromSelector(selector);

            if (InheritFromBaseClass)
            {
                _classBuilder.AddInheritance(Consts.DRIVER_CONTAINER_CLASS_NAME);
            }
            string body = _classBuilder
                          .AddUsings(GetUsings(elements))
                          .AddCtor(CreateCtor(className))
                          .SetClassName(className)
                          .SetNamesapce(NamespaceName)
                          .AddUsings(GetUsings(elements))
                          .AddProperties(GetProperties(elements))
                          .AddMethods(GetHelpers(className, elements))
                          .AddFields(GetFields())
                          .Build();

            return(new ComponentGeneratorOutput
            {
                Body = body,
                CsFilePath = NamespaceFileConverter.ConvertNamespaceToFilePath(NamespaceName, className)
            });
        }
        public virtual IComponentAddin MakeAddin(string selector)
        {
            string name = SelectorUtils.GetClassOrPropNameFromSelector(selector);

            return(new FileCreatorAddin
            {
                AddinKey = name,
                RequiredUsings = new[] { NamespaceName }
            });
        }
Example #3
0
        private static string GetWaiterBulk(string selector)
        {
            string waiterFieldName = "wait" + SelectorUtils.GetClassOrPropNameFromSelector(selector);
            string waiter          = $"var {waiterFieldName} = new WebDriverWait({Consts.DRIVER_FIELD_NAME},TimeSpan.FromSeconds(5));";
            string waiting         = $"{waiterFieldName}.Until(ExpectedConditions.ElementIsVisible(By.ClassName(\"{selector}'\")));";

            return(new StringBuilder()
                   .AppendLine(waiter)
                   .AppendLine(waiting)
                   .ToString());
        }
Example #4
0
        public override IComponentAddin MakeAddin(string selector)
        {
            string name = SelectorUtils.GetClassOrPropNameFromSelector(selector);

            return(new FileCreatorAddin
            {
                AddinKey = name,
                CtorContainsDriver = false,
                RequiredUsings = new[] { NamespaceName }
            });
        }
        public string[] GenerateHelpers(string className, string selector, IPropertyGenerator generator)
        {
            string        propName = SelectorUtils.GetClassOrPropNameFromSelector(selector);
            string        propertyNameFromGenerator = generator.GetPropertyName(Type, propName);
            string        methodPropName            = TextUtils.UppercaseFirst(propName);
            StringBuilder builder = new StringBuilder();
            string        helper  = builder
                                    .AppendLine($"public {className} With{methodPropName}(string {propName})")
                                    .AppendLine("{")
                                    .AppendLine($"{propertyNameFromGenerator}.SendKeys({propName});")
                                    .AppendLine("return this;")
                                    .AppendLine("}")
                                    .ToString();

            return(new [] { helper });
        }