问题
I have an app very similar to Google/Yahoo map. I search for a location and it is displayed on map. When I see html of page, there are many segments and all of them are images. I wonder if there is any way to verify that text for searched location is available on page.
For example if I search
http://maps.yahoo.com/#mvt=m&lat=36.298746&lon=-115.139974&zoom=12&q1=las%20vegas
There would be "Las Vegas" displayed on page. Now how do I verify that "Las Vegas" is really displayed on page?
回答1:
So you want to check that the text in the image with selenium. You will need to grab the url of the image, download that image, and put it through an OCR program.
So short answer, not with selenium
回答2:
Sikuli allows verification of images, or parts of images. I've not tried it, or tried to integrate it with Selenium, but the concepts of what Sikuli can do, looks really good. Take a look at the project here: http://sikuli.org/
回答3:
Actually I threat this here:
- Shows you how you can compare 2 images and get a differences image or a gif animation with the overlapping of the first 2:
http://testautomationexperiences.com/detect-layout-issues-using-file-hashes-and-imagemagick-for-compare/
- Do it in Selenium by using im4java and imagemagick; also the hash checking is the first step in verification:
http://testautomationexperiences.com/detect-layout-issues-using-file-hashes-and-imagemagick-for-compare-coding-in-java/
I hope it helps, even is not OCR.
For OCR, you need a library (created by you or an existing one) which you call from selenium.
Good luck, Claudiu Adam
http://testautomationexperiences.com/
来源:https://stackoverflow.com/questions/5660424/could-i-verify-text-in-image-using-selenium