1

Is it possible to have Selenium Basic (via VBA) to output a screenshot as a base64 image?

I can successfully take a screenshot using:

Set sc = element.TakeScreenshot

I have tried:

sc.getScreenshotAsBase64

But it doesn't work. Is this possible to achieve?

Thanks.

drec4s
  • 7,946
  • 8
  • 33
  • 54

1 Answers1

0

You can use selenium only to take screenshot and convert into base64 form

   String Base64StringofScreenshot="";
    File src = ((TakesScreenshot) driverThread).getScreenshotAs(OutputType.FILE);
    byte[] fileContent = FileUtils.readFileToByteArray(src);
    Base64StringofScreenshot = "data:image/png;base64,"+Base64.getEncoder().encodeToString(fileContent);
ravi creed
  • 371
  • 3
  • 6
  • This is not c#, its java – ravi creed Feb 03 '19 at 16:50
  • I am not sure in VBA, But i can tell u the steps..1.take screenshot and store it in object 2.convert the object into bytearray 3.convert the byte array into base64string and add 'data:image/png;base64,' substring before it, there you have your base64 string – ravi creed Feb 03 '19 at 16:50