package com.tngtech.jgiven.report.html5;

import static org.assertj.core.api.Assertions.assertThat;

import java.io.File;
import java.util.List;

import org.openqa.selenium.*;

import com.tngtech.jgiven.CurrentStep;
import com.tngtech.jgiven.Stage;
import com.tngtech.jgiven.annotation.ExpectedScenarioState;
import com.tngtech.jgiven.attachment.Attachment;
import com.tngtech.jgiven.attachment.MediaType;

public class Html5AppStage<SELF extends Html5AppStage<?>> extends Stage<SELF> {
    @ExpectedScenarioState
    protected CurrentStep currentStep;

    @ExpectedScenarioState
    protected WebDriver webDriver;

    @ExpectedScenarioState
    protected File targetReportDir;

    protected void takeScreenshot() {
        String base64 = ( (TakesScreenshot) webDriver ).getScreenshotAs( OutputType.BASE64 );
        currentStep.addAttachment( Attachment.fromBase64( base64, MediaType.PNG ).withTitle( "Screenshot" ) );
    }

    protected WebElement findTagWithName( String tagName ) {
        List<WebElement> links = webDriver.findElements(
            By.xpath( String.format( "//a/span[contains(@class,'tag') and contains(text(), '%s')]/..", tagName ) ) );
        assertThat( links ).isNotEmpty();
        return links.get( 0 );
    }

}

@@ -98,84 +98,8 @@
 t;%0A%0A
-import java.io.File;%0Aimport java.util.List;%0A%0Aimport org.openqa.selenium.*;%0A%0A
 impo
@@ -322,16 +322,90 @@
 diaType;
+%0Aimport java.io.File;%0Aimport java.util.List;%0Aimport org.openqa.selenium.*;
 %0A%0Apublic
@@ -735,17 +735,16 @@
 se64 = (
- 
 (TakesSc
@@ -762,17 +762,16 @@
 ebDriver
- 
 ).getScr
@@ -780,17 +780,16 @@
 nshotAs(
- 
 OutputTy
@@ -797,17 +797,16 @@
 e.BASE64
- 
 );%0A     
@@ -834,17 +834,16 @@
 achment(
- 
 Attachme
@@ -856,17 +856,16 @@
 mBase64(
- 
 base64, 
@@ -877,17 +877,16 @@
 Type.PNG
- 
 ).withTi
@@ -889,17 +889,16 @@
 thTitle(
- 
 %22Screens
@@ -901,19 +901,17 @@
 eenshot%22
- ) 
+)
 );%0A    %7D
@@ -953,17 +953,16 @@
 ithName(
- 
 String t
@@ -967,17 +967,16 @@
  tagName
- 
 ) %7B%0A    
@@ -1040,16 +1040,20 @@
         
+ 
+   
 By.xpath
@@ -1053,17 +1053,16 @@
 y.xpath(
- 
 String.f
@@ -1067,17 +1067,16 @@
 .format(
- 
 %22//a/spa
@@ -1144,13 +1144,10 @@
 Name
- ) ) 
+))
 );%0A 
@@ -1164,23 +1164,21 @@
 ertThat(
- 
 links
- 
 ).isNotE
@@ -1214,11 +1214,9 @@
 get(
- 0 
+0
 );%0A 

Reformat code