@@ -39,7 +39,7 @@ public class ResponsiveUIValidator {
3939 static boolean drawRightOffsetLine = false ;
4040 static boolean drawTopOffsetLine = false ;
4141 static boolean drawBottomOffsetLine = false ;
42- static boolean isMobileTopBar = false ;
42+ private static boolean isMobileTopBar = false ;
4343 private static boolean withReport = false ;
4444 private static String scenarioName = "Default" ;
4545 private static Color rootColor = new Color (255 , 0 , 0 , 255 );
@@ -50,6 +50,7 @@ public class ResponsiveUIValidator {
5050 private static BufferedImage img ;
5151 private static Graphics2D g ;
5252 private static JSONArray errorMessage ;
53+ private static List <String > jsonFiles = new ArrayList <>();
5354 String rootElementReadableName = "Root Element" ;
5455 List <WebElement > rootElements ;
5556 ResponsiveUIValidator .Units units = PX ;
@@ -201,11 +202,13 @@ public boolean validate() {
201202 }
202203
203204 long ms = System .currentTimeMillis ();
204- try (Writer writer = new BufferedWriter (new OutputStreamWriter (new FileOutputStream (TARGET_AUTOMOTION_JSON + rootElementReadableName .replace (" " , "" ) + "-automotion" + ms + ".json" ), StandardCharsets .UTF_8 ))) {
205+ String jsonFileName = rootElementReadableName .replace (" " , "" ) + "-automotion" + ms + ".json" ;
206+ try (Writer writer = new BufferedWriter (new OutputStreamWriter (new FileOutputStream (TARGET_AUTOMOTION_JSON + jsonFileName ), StandardCharsets .UTF_8 ))) {
205207 writer .write (jsonResults .toJSONString ());
206208 } catch (IOException ex ) {
207209 LOG .error ("Cannot create json report: " + ex .getMessage ());
208210 }
211+ jsonFiles .add (jsonFileName );
209212 try {
210213 File file = new File (TARGET_AUTOMOTION_JSON + rootElementReadableName .replace (" " , "" ) + "-automotion" + ms + ".json" );
211214 if (file .getParentFile ().mkdirs ()) {
@@ -235,9 +238,9 @@ public boolean validate() {
235238 * Call method to generate HTML report
236239 */
237240 public void generateReport () {
238- if (withReport && isAutomotionFolderExists ()) {
241+ if (withReport && ! jsonFiles . isEmpty ()) {
239242 try {
240- new HtmlReportBuilder ().buildReport ();
243+ new HtmlReportBuilder ().buildReport (jsonFiles );
241244 } catch (IOException | ParseException | InterruptedException e ) {
242245 e .printStackTrace ();
243246 }
@@ -250,9 +253,9 @@ public void generateReport() {
250253 * @param name
251254 */
252255 public void generateReport (String name ) {
253- if (withReport && isAutomotionFolderExists ()) {
256+ if (withReport && ! jsonFiles . isEmpty ()) {
254257 try {
255- new HtmlReportBuilder ().buildReport (name );
258+ new HtmlReportBuilder ().buildReport (name , jsonFiles );
256259 } catch (IOException | ParseException | InterruptedException e ) {
257260 e .printStackTrace ();
258261 }
0 commit comments