Skip to content

Commit

Permalink
Merge pull request #23 from ing-bank/fix/multiplebrowsernotclosing
Browse files Browse the repository at this point in the history
Fix/multiplebrowsernotclosing
  • Loading branch information
psupriya15 authored Sep 2, 2024
2 parents 4849fd1 + 65aa18b commit 7134112
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions Engine/src/main/java/com/ing/engine/core/Task.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

package com.ing.engine.core;

import com.ing.datalib.component.Project;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7134112

Please sign in to comment.