Skip to content

Commit 5f0e4ef

Browse files
committed
tracePath
1 parent a8afd68 commit 5f0e4ef

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

playwright/src/main/java/com/microsoft/playwright/impl/BrowserImpl.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import java.util.*;
2929
import java.util.function.Consumer;
3030

31-
import static com.microsoft.playwright.impl.Serialization.addHarUrlFilter;
3231
import static com.microsoft.playwright.impl.Serialization.gson;
3332
import static com.microsoft.playwright.impl.Utils.*;
3433

@@ -39,7 +38,7 @@ class BrowserImpl extends ChannelOwner implements Browser {
3938
private boolean isConnected = true;
4039
BrowserTypeImpl browserType;
4140
BrowserType.LaunchOptions launchOptions;
42-
private Path tracesDir;
41+
private Path tracePath;
4342
String closeReason;
4443

4544
enum EventType {
@@ -199,7 +198,7 @@ private void startTracingImpl(Page page, StartTracingOptions options) {
199198
if (options == null) {
200199
options = new StartTracingOptions();
201200
}
202-
tracesDir = options.path;
201+
tracePath = options.path;
203202
JsonObject params = gson().toJsonTree(options).getAsJsonObject();
204203
if (page != null) {
205204
params.add("page", ((PageImpl) page).toProtocolRef());
@@ -217,14 +216,14 @@ private byte[] stopTracingImpl() {
217216
ArtifactImpl artifact = connection.getExistingObject(json.getAsJsonObject().getAsJsonObject("artifact").get("guid").getAsString());
218217
byte[] data = artifact.readAllBytes();
219218
artifact.delete();
220-
if (tracesDir != null) {
219+
if (tracePath != null) {
221220
try {
222-
Files.createDirectories(tracesDir.getParent());
223-
Files.write(tracesDir, data);
221+
Files.createDirectories(tracePath.getParent());
222+
Files.write(tracePath, data);
224223
} catch (IOException e) {
225224
throw new PlaywrightException("Failed to write trace file", e);
226225
} finally {
227-
tracesDir = null;
226+
tracePath = null;
228227
}
229228
}
230229
return data;
@@ -274,7 +273,7 @@ protected void connectToBrowserType(BrowserTypeImpl browserType, Path tracesDir)
274273
// Note: when using connect(), `browserType` is different from `this.parent`.
275274
// This is why browser type is not wired up in the constructor, and instead this separate method is called later on.
276275
this.browserType = browserType;
277-
this.tracesDir = tracesDir;
276+
this.tracePath = tracesDir;
278277

279278
for (BrowserContextImpl context : contexts) {
280279
context.tracing().setTracesDir(tracesDir);
@@ -288,7 +287,7 @@ private void didCreateContext(BrowserContextImpl context) {
288287
// Note: when connecting to a browser, initial contexts arrive before `_browserType` is set,
289288
// and will be configured later in `ConnectToBrowserType`.
290289
if (browserType != null) {
291-
context.tracing().setTracesDir(tracesDir);
290+
context.tracing().setTracesDir(tracePath);
292291
browserType.playwright.sharedSelectors.contextsForSelectors.add(context);
293292
}
294293
}

0 commit comments

Comments
 (0)