0

I want to convert an image to Base64. I test a website and an image URL expires after 3s and change after 3s and reload auto in the page? Is there a way to take it from the locally loaded copy as base64 string?

I use Javascript, I take a look 1 article like but it's write with C#. I want convert it to Javascript.

I do not know if there is an alternative solution.

Can you suggest other solutions?

Thanks.

Gnqz
  • 3,292
  • 3
  • 25
  • 35
  • possible duplicate of [How to convert image into base64 string using javascript](http://stackoverflow.com/questions/6150289/how-to-convert-image-into-base64-string-using-javascript) – JeffC Aug 18 '15 at 15:15

1 Answers1

0
var image = driver.findElement(webdriver.By.Id('id of image tag'));

after this, you can get the src attribute

image.getAttribute('src').then(function(src) {
   //download the image using the driver and store it
});

wait 3 seconds using driver.wait

driver.wait(function() {
  //load the image again and compare
}, 3000);
Advicer
  • 1,300
  • 1
  • 14
  • 26
  • Thanks. But I want convert image to base64 because this image will auto change after 3s. Your answer save src image but after 3s it do not appear. –  Aug 18 '15 at 09:48
  • Can your explain me where are src in? How to call it? Thank you. –  Aug 18 '15 at 09:54