Thank you for the complete error report. I was able to reproduce the problem and it looks
like you found a bug in FLB, which I need to look into ...
But because you have no animation on your web pages, you can use the SimpleTextDetector
instead of the default AnimationAwareTextDetector to circumvent the problem. I have refactored
public class Layoutmain {
public static void main(String[] args) {
File screenshotDir = new File("H:\\Selenium\\screenshots");
WebDriver driver = new FirefoxDriver();
try {
driver.get(testPageUrl);
analyzePageWithFLB(driver, screenshotDir);
List<String> urls = scanLinks(driver);
for (String url : urls) {
driver.get(url);
analyzePageWithFLB(driver, screenshotDir);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
driver.quit();
}
}
private static List<String> scanLinks(WebDriver driver) {
List<String> urls = new ArrayList<String>();
List<WebElement> links = driver.findElements(By.tagName("a"));
for (WebElement a : links) {
String href = a.getAttribute("href");
urls.add(href);
}
return urls;
}
private static void analyzePageWithFLB(WebDriver driver, File screenshotDir) {
WebPage webPage = new WebPage(driver);
System.out.println("Analyzing " + webPage.getUrl() + " ...");
FightingLayoutBugs flb = new FightingLayoutBugs();
flb.setTextDetector(new SimpleTextDetector()); // <-- this is the important line ;)
flb.setScreenshotDir(screenshotDir);
// flb.enableDebugMode();
final Collection<LayoutBug> layoutBugs = flb.findLayoutBugsIn(webPage);
if (!layoutBugs.isEmpty()) {
System.err.println(
"Found " + layoutBugs.size() + " layout bug(s):\n" +
Joiner.on("\n").join(layoutBugs)
);
}
}
}