How to test images with selenium


632
632 points
how to test images with selenium
how to test images with selenium

How to test images with selenium

Selenium manipulates the browser , thats it , what can you do with that power it’s entirely up to you. So how to test images with selenium?

First of all we need to get the image url that we want to test:

image_url = find(tag_name: 'img')
# @return [Boolean] # @param [String] url # def remote_image_exists?(url) url = URI.parse(url) http = Net::HTTP.new(url.host, url.port) http.use_ssl = (url.scheme == 'https') http.start do |http| return http.head(url.request_uri)['Content-Type'].start_with? 'image' end end
assert_true(remote_image_exists?(image_url)) 

You can find multiple example to use a proxy , or a rest client or a java script solution here.

Happy testing!


Like it? Share with your friends!

632
632 points

What's Your Reaction?

cute cute
0
cute
scary scary
0
scary
wtf wtf
0
wtf
geek geek
0
geek
WIN WIN
0
WIN
Love Love
0
Love
OMG OMG
0
OMG
Angry Angry
0
Angry
Lol Lol
0
Lol
Test engineer

0 Comments

Your email address will not be published. Required fields are marked *

Choose A Format
Trivia quiz
Story