In order to get the src
attribute from an image you need to use the getSrcAttribute()
method. Suppose myImage
is an HtmlImage object, this code would output the src
attribute to the console:
System.out.println(myImage.getSrcAttribute());
As a side note, casting an image as an HtmlPage
will most likely throw an exception.