Jasmine.Olivra
Jasmine.Olivra

Reputation: 1771

save image from website using selenium webdriver

I am testing web application which can help to extract text from image using Optical Character Recognition.

Steps for explanation is

  1. Enter text to convert in Image using [Convert text to image] utility .

  2. Now we have developed OCR app to extract this text from image.

I want to take save this image and pass it to OCR app which is web based applicaion.

So I want to know how to save this text image to drive

Example: http://www.textimg.net/

enter image description here

Upvotes: 1

Views: 1645

Answers (1)

Nora
Nora

Reputation: 1482

I don't think there's an easy way using selenium webdriver, however, I think you can get the link of the image using webdriver, then use whatever language you're using to download the file, for example, if you're using ruby you can use the below code, it will create a new file called image.png and copy the image from url:

require 'open-uri'
open('image.png', 'wb') do |file|
  file << open('http://www.textimg.net/textimages/2012/this-text-image-tool-is-so-cool-_502153c0c5fa7.png').read
end

Upvotes: 3

Related Questions