Skip to content

Commit

Permalink
add exception handling for dangling elements
Browse files Browse the repository at this point in the history
  • Loading branch information
Long Pham committed May 24, 2018
1 parent 16ce748 commit b272dd9
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 33 deletions.
58 changes: 29 additions & 29 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ public static void main (String[] args) {
System.out.println(doc.getTitle());
System.out.println(doc.get(CoreAnnotations.TokensAnnotation.class).size());
for (CoreLabel token : doc.get(CoreAnnotations.TokensAnnotation.class)) {
System.out.println(token.word() + " " + token.ner() + " " +
String word = token.word();
if (token.containsKey(CustomizableCoreAnnotations.TypeAnnotation.class)) {
word = token.get(CustomizableCoreAnnotations.TypeAnnotation.class);
}
System.out.println(word + " " + token.ner() + " " +
token.get(CustomizableCoreAnnotations.LayoutHeightAnnotation.class) + " " +
token.get(CustomizableCoreAnnotations.LayoutWidthAnnotation.class));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ private static int travelDOMTreeWithSelenium(RemoteWebElement e, StringBuilder s
}

private static void travelDOMTreeWithSelenium(RemoteWebElement e, Rectangle r, List<CoreLabel> allTokens, WebDriver driver) {
try {
e.isDisplayed();
} catch (Exception ex) {
System.out.println("Some dangling nodes are found in this URL");
System.err.println("Some dangling nodes are found in this URL");
return;
}
if (e.isDisplayed()) {
Rectangle rec = null;
try {
Expand Down Expand Up @@ -284,7 +291,7 @@ public static void main(String[] args) {
String filename = urls.get(i).first;
String baseUrl = urls.get(i).second;

System.out.println(i + "\t" + baseUrl);
System.out.println(filename + "\t" + baseUrl);

WebDriver driver = createChromeDriver();
// System.out.println(getAllTextWithLayout(driver,baseUrl));
Expand Down
5 changes: 3 additions & 2 deletions test_urls.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
0 http://charm.cs.illinois.edu/research/episim
1 http://www.forwarddatalab.org/kevinchang
0 https://cs.illinois.edu/about-us/awards/faculty-awards/chairs-and-professorships/founder-professor-engineering
1 http://data-people.cs.illinois.edu/topic.html
2 http://charm.cs.illinois.edu/research/episim

0 comments on commit b272dd9

Please sign in to comment.