if (screenshot) {
TakeScreenshotService service = getNativeDriver().getScreenshotService();
if (service instanceof InstrumentsAppleScreenshotService) {
File source = ((InstrumentsAppleScreenshotService) service).getScreenshotFile();
JSONWireImage image = new InstrumentsGeneratedImage(source, o);
try {
String content64 = image.getAsBase64String();
value.put("screenshot", ImmutableMap.of("64encoded", content64));
} catch (Exception e) {
throw new WebDriverException(
"Error converting " + source.getAbsolutePath() + " to a 64 encoded string "
+ e.getMessage(), e);