public PageMemberCodeEntry GetEntryExpected(HtmlDocument document, Type[] applicableAnalyzers, int elementPosition) { var pageLoader = new AwesomiumPageLoader(); var entries = new List <IPageMemberCodeEntry>(); entries.AddRange(pageLoader.GetCodeEntriesFromNode(document.DocumentNode, ExcludeList, applicableAnalyzers)); return(entries.Cast <PageMemberCodeEntry>().ToArray()[elementPosition]); }
public List <IPieceOfPackage> GetPiecesOfCodeCollection(HtmlDocument document, Type[] applicableAnalyzers) { var pageLoader = new AwesomiumPageLoader(); var entries = new List <IPieceOfPackage>(); // TODO: temporarily entries.Add(CodeFile.NewPage("page")); entries.AddRange(pageLoader.GetCodeEntriesFromNode(document.DocumentNode, ExcludeList, applicableAnalyzers)); return(entries); }
public PageMemberCodeEntry GetEntryExpected(HtmlDocument document, Type[] applicableAnalyzers, string expectedTypeName) { var pageLoader = new AwesomiumPageLoader(); var entries = new List <IPageMemberCodeEntry>(); entries.AddRange(pageLoader.GetCodeEntriesFromNode(document.DocumentNode, ExcludeList, applicableAnalyzers)); // TODO: IndexOf '<' if (expectedTypeName.Substring(expectedTypeName.Length - 1) == "<") { expectedTypeName = expectedTypeName.Substring(0, expectedTypeName.Length - 1); } return(entries.Cast <PageMemberCodeEntry>().First(entry => entry.JdiMemberType == Enum.GetValues(typeof(JdiElementTypes)).Cast <JdiElementTypes>().First(item => "I" + item.ToString() == expectedTypeName))); }
static void Main(string[] args) { //var list1 = new List<HtmlElementTypes>(); //list1.AddRange(new [] { HtmlElementTypes.Html, HtmlElementTypes.A, HtmlElementTypes.Abbr, }); var pageSource = string.Empty; var list = new List <string> { //// "file:///C:/1/bootstrap.html", //"http://*****:*****@"\" + (300 + fileNumber))) { writer.WriteLine(@"// {0}", url); entries.ToList().ForEach(elementDefinition => { var codeEntryString = elementDefinition.GenerateCode(SupportedTargetLanguages.Java); Console.WriteLine(codeEntryString); writer.WriteLine(codeEntryString); }); writer.Flush(); writer.Close(); } /* * // driver.findElement(By.xpath()) * // driver.findElement(By.className()) * // driver.findElement(By.cssSelector()) * // driver.findElement(By.id()) * // driver.findElement(By.linkText()) * // driver.findElement(By.name()) * // driver.findElement(By.partialLinkText()) * // driver.findElement(By.tagName()) */ // 20160715 var onlyPageMembers = entries .Where(entry => PageObjectParts.CodeOfMember == entry.CodeClass) .Cast <IPageMemberCodeEntry>() .ToList(); using (var tempWriter = new StreamWriter(folderForExportFiles + @"\" + (400 + fileNumber))) { // this worked // entries.ToList().ForEach(eltDef => tempWriter.WriteLine("try {{ elementFound = \"0\"; elementDisplayed = \"0\"; allElementsNumber++; WebElement element = driver.findElement(By.{0}(\"{1}\")); foundElementsNumber++; elementFound = \"1\"; if (element.isDisplayed()) {{ displayedElementsNumber++; elementDisplayed = \"1\"; }} }} catch (Exception e) {{ System.out.println(\"failed: {1}\"); }} writeData(fileWriter, \"{0}\", \"{1}\", elementFound, elementDisplayed);", // 20160715 // TODO: work only with code entries // entries.ToList().ForEach(eltDef => tempWriter.WriteLine("testLocator(By.{0}(\"{1}\"), \"{0}\", \"{1}\");", onlyPageMembers .ForEach(eltDef => tempWriter.WriteLine("testLocator(By.{0}(\"{1}\"), \"{0}\", \"{1}\");", // static void testLocator(org.openqa.selenium.By by, String locatorName, String locatorPath) { eltDef.Locators.Any() ? eltDef.Locators.First(loc => loc.IsBestChoice).ElementSearchTypePreference.ToString() : "_", eltDef.Locators.Any() ? eltDef.Locators.First(loc => loc.IsBestChoice).SearchString : "_" )); tempWriter.Flush(); tempWriter.Close(); } // 20160715 // exporter.WriteToFile(entries, folderForExportFiles + @"\" + (100 + ++fileNumber)); exporter.WriteToFile(onlyPageMembers, folderForExportFiles + @"\" + (100 + ++fileNumber)); var importedEntries = importer.LoadFromFile <HtmlElementTypes>(folderForExportFiles + @"\" + (100 + fileNumber)); exporter.WriteToFile(importedEntries, folderForExportFiles + @"\" + (200 + fileNumber)); }); Console.WriteLine("Completed!"); Console.ReadKey(); }