Could I verify text in image using Selenium

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 00:45:19

问题


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:

  1. 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/

  1. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!