NullPointerException on image verification in Selenium
<p>I am using Selenium Server with Java and trying to verify that an image is actually displayed. 
I am using the following code, but getting <code>NullPointerException</code>:</p>

<pre><code>String imageURL = driver.findElement(By.xpath(imageXpath)).getAttribute("src");
assertTrue((Boolean) ((JavascriptExecutor)driver).executeScript("return arguments[0].complete &amp;&amp; typeof arguments[0].naturalWidth != \"undefined\" &amp;&amp; arguments[0].naturalWidth &gt; 0", imageURL));
</code></pre>

<p>When I manually verify the URL stored in the variable <code>imageURL</code> I am getting a valid image, therefore I don't understand why am I getting a <code>NullPointerException</code>?</p>