From 65aa18b96bae804b1cb3bb725d6eec6a9ead7d4d Mon Sep 17 00:00:00 2001 From: Ashish Date: Sun, 1 Sep 2024 12:33:47 +0200 Subject: [PATCH] Added playwright close for every iteration --- .../main/java/com/ing/engine/core/Task.java | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Engine/src/main/java/com/ing/engine/core/Task.java b/Engine/src/main/java/com/ing/engine/core/Task.java index c2f6217..f27d25c 100644 --- a/Engine/src/main/java/com/ing/engine/core/Task.java +++ b/Engine/src/main/java/com/ing/engine/core/Task.java @@ -1,4 +1,3 @@ - package com.ing.engine.core; import com.ing.datalib.component.Project; @@ -67,12 +66,13 @@ public void run() { try { System.out.println("Running Iteration " + iter); runIteration(iter++); + closePlaywrightInstance(iter-1); } catch (Exception ex) { LOG.log(Level.SEVERE, ex.getMessage(), ex); } } Date endEexcDate = new Date(); - + if (report != null) { Status s = report.finalizeReport(); Control.ReportManager.startDate = startexecDate; @@ -82,6 +82,25 @@ public void run() { } } + private void closePlaywrightInstance(int iter) { + String browserName = playwrightDriver.getCurrentBrowser(); + if (playwrightDriver != null) { + playwrightDriver.closeBrowser(); + playwrightDriver.playwright.close(); + } + String closureConfirmationText = "Playwright instance with [" + browserName + "] has been closed for Iteration : " + iter; + System.out.println("\n"); + for (int i = 0; i < closureConfirmationText.length() + 7; i++) { + System.out.print("-"); + } + System.out.println(); + System.out.println("| " + closureConfirmationText + " |"); + for (int i = 0; i < closureConfirmationText.length() + 7; i++) { + System.out.print("-"); + } + System.out.println("\n"); + } + private TestCase getTestCase() { try { Scenario scn = project().getScenarioByName(runContext.Scenario); @@ -144,7 +163,7 @@ private void launchBrowser() throws UnCaughtException { } private CommandControl createControl() { - return new CommandControl(playwrightDriver,playwrightDriver,playwrightDriver, report) { + return new CommandControl(playwrightDriver, playwrightDriver, playwrightDriver, report) { @Override public void execute(String com, int sub) { runner.runTestCase(com, sub);