0

I am creating some selenium test in ruby to check my web page.

Is there any way to check background-image is loaded or not using selenium webdriver or javascript.

there is css for background image

.banner {
background-image:url('http://dev.nestaway.in/assets/banner_slide1.jpg')
...  //some other attributes
}

And html looks like this

<div class = 'banner' style='width:100px; height:75px'>
   <h1>this is main heading</h1>
   <p>this is some paragraph</p>
</div>

I know that I can check for 'img' but this doesn't work when images are in css background. For IMG tag images I can check

ele = document.getElementById('image_id');

return ele.complete && ele.naturalWidth > 0 && ele.naturalWidth != 'undefined'

Please Suggest some solution.

Thanks in advance.

  • http://stackoverflow.com/questions/6338217/get-a-css-value-with-javascript check this it might be helpful to you.. – Anant Dabhi Feb 12 '15 at 11:22
  • @AnantDabhi actually I want to check if background is loaded or not like for we can check if its loaded or not – Rohit Kumar Feb 12 '15 at 11:28
  • Not familiar with Ruby but I would suggest the equivalent of item.GetCssValue("background-image") and checking the width of the image to understand if it has been loaded. – aberna Feb 12 '15 at 14:37

0 Answers0