Exemplo n.º 1
0
        private static void GeneratePageObjects(DotvvmProjectMetadata dotvvmProjectMetadata,
                                                DotvvmConfiguration dotvvmConfig,
                                                Arguments arguments)
        {
            var options   = PrepareSeleniumGeneratorOptions(dotvvmConfig);
            var generator = new SeleniumPageObjectGenerator(options, dotvvmConfig);

            IEnumerable <string> controlFiles = new List <string>();
            IEnumerable <string> viewFiles;

            if (arguments[0] != null)
            {
                var parsedArguments = SplitArguments(arguments);
                viewFiles = GetViewsFiles(parsedArguments);
            }
            else
            {
                // generate all views and user controls files if no argument was specified
                viewFiles    = dotvvmConfig.RouteTable.Where(b => b.VirtualPath != null).Select(r => r.VirtualPath);
                controlFiles = dotvvmConfig.Markup.Controls.Where(b => b.Src != null).Select(c => c.Src);
            }

            var allFiles = controlFiles.Concat(viewFiles).Distinct();

            foreach (var file in allFiles)
            {
                if (File.Exists(file))
                {
                    Console.WriteLine($"Generating stub for {file}...");

                    // determine full type name and target file
                    var relativePath     = PathHelpers.GetDothtmlFileRelativePath(dotvvmProjectMetadata, file);
                    var relativeTypeName = $"{PathHelpers.TrimFileExtension(relativePath)}PageObject";
                    var fullTypeName     = $"{dotvvmProjectMetadata.UITestProjectRootNamespace}.{PageObjectsText}.{PathHelpers.CreateTypeNameFromPath(relativeTypeName)}";
                    var targetFileName   = Path.Combine(dotvvmProjectMetadata.UITestProjectPath, PageObjectsText, relativeTypeName + ".cs");

                    var config = GetSeleniumGeneratorConfiguration(fullTypeName, targetFileName, file);

                    GeneratePageObject(generator, config);
                }
            }
        }
 public SeleniumPageObjectVisitor(SeleniumPageObjectGenerator seleniumGenerator)
 {
     this.seleniumGenerator = seleniumGenerator;
     generators             = new Dictionary <Type, ISeleniumGenerator>();
 }
Exemplo n.º 3
0
 private static void GeneratePageObject(SeleniumPageObjectGenerator generator,
                                        SeleniumGeneratorConfiguration config)
 => generator.ProcessMarkupFile(config);