title: Selenium webdriver: Export screenshot to robot framework log file
body: <p>I'm using selenium webdriver together with robot framework and I have the following problem:</p>
  
  <p>I want to make a screenshot every time my tests fail and export this screenshot to log.html file.</p>
  
  <p>Making screenshot is quity an easy thing:</p>
  
  <pre><code>    String path;
      try {
          WebDriver augmentedDriver = new Augmenter().augment(driver);
          File source = ((TakesScreenshot) augmentedDriver)
                  .getScreenshotAs(OutputType.FILE);
          path = "./screenshots/" + source.getName();
          FileUtils.copyFile(source, new File(path));
      } catch (IOException e) {
          path = "Failed to capture screenshot: " + e.getMessage();
      }
  </code></pre>
  
  <p>But the problem is to export the screenshot as html.</p>
  
  <p>In selenium RC the html part with screenshot looks like this:</p>
  
  <pre><code>&lt;tbody&gt;
      &lt;tr&gt;
          &lt;td class="time"&gt;15:25:44.968&lt;/td&gt;
          &lt;td class="fail level"&gt;FAIL&lt;/td&gt;
          &lt;td class="message"&gt;Value of text field 'xpath=//input' should have been '' but was 'VpomRihh3Xa' Screenshot: &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td colspan="3"&gt;
              &lt;img src="./screenshots/screenshot175324738088103861.png"&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
  </code></pre>
  
  <p>Okey, so I thought that should be an easy to implement and extended my captureScreenshot() function to this:</p>
  
  <pre><code>private String captureScreen() {
  
      String path;
      try {
          WebDriver augmentedDriver = new Augmenter().augment(driver);
          File source = ((TakesScreenshot) augmentedDriver)
                  .getScreenshotAs(OutputType.FILE);
          path = "./screenshots/" + source.getName();
          FileUtils.copyFile(source, new File(path));
      } catch (IOException e) {
          path = "Failed to capture screenshot: " + e.getMessage();
      }
  
      StringBuilder builder = new StringBuilder();
  
      builder.append("\n&lt;tr&gt;&lt;td colspan=\"3\"&gt;&lt;img src=\"").append(path).append("\"&gt;&lt;/tr&gt;&lt;/td&gt;");
  
      System.out.println(builder.toString());
  
      return "";
  
  }
  </code></pre>
  
  <p>But the problem is, that this implementation is not acceptable for my needs. It looks good, but all I get is some text inside  tag, that will be not displayed as an image.</p>
  
  <p>To understand it better here is the screenshot from what I get:</p>
  
  <p><a href="http://gyazo.com/5d7dec1e05443786b5d390054edad3e8" rel="nofollow">http://gyazo.com/5d7dec1e05443786b5d390054edad3e8</a>
  (can't post image due to low reputation)</p>
  
  <p>So the question is - how to get screenshot imported to robot framework log.html file?</p>