Yep, the solution that david provided works, here's a quick test.
@Test
public void testImageShown(){
WebDriver driver = new FirefoxDriver();
driver.get("
https://dl.dropboxusercontent.com/u/3147870/broken_image.html");
WebElement brokenImage = driver.findElement(By.xpath("//div[@id=\"1\"]/img"));
WebElement notSoBroken = driver.findElement(By.xpath("//div[@id=\"2\"]/img"));
WrapsDriver wrapsDriver = (WrapsDriver) brokenImage;
String script = "return (typeof arguments[0].naturalWidth!=\"undefined\"" +
" && arguments[0].naturalWidth>0)";
JavascriptExecutor javascriptExecutor = (JavascriptExecutor) wrapsDriver.getWrappedDriver();
Object isBrokenShown = javascriptExecutor.executeScript(script, brokenImage);
Object isNotBrokenShown = javascriptExecutor.executeScript(script, notSoBroken);
}
returns
false
true
br.
e