Skip to content

Commit

Permalink
Fix quarkiverse#59: Added recordVideoDir option
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Jul 3, 2024
1 parent fa0cd40 commit 1014f8c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<dependency>
<groupId>io.quarkiverse.web-bundler</groupId>
<artifactId>quarkus-web-bundler</artifactId>
<version>1.5.0.CR2</version>
<version>1.6.0</version>
</dependency>
<dependency>
<groupId>io.quarkiverse.qute.web</groupId>
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
<tag>HEAD</tag>
</scm>
<properties>
<compiler-plugin.version>3.12.1</compiler-plugin.version>
<compiler-plugin.version>3.13.0</compiler-plugin.version>
<maven.compiler.release>11</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.version>3.3.1</quarkus.version>
<playright.version>1.41.2</playright.version>
<playright.version>1.44.0</playright.version>
</properties>
<dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -75,4 +75,4 @@
</modules>
</profile>
</profiles>
</project>
</project>
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package io.quarkiverse.playwright;

import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

import com.microsoft.playwright.Browser;
import com.microsoft.playwright.BrowserContext;
import com.microsoft.playwright.BrowserType;
Expand Down Expand Up @@ -51,7 +54,12 @@ public Map<String, String> start() {
.setArgs(Arrays.asList(this.options.args()));
this.playwrightBrowser = browser(playwright, this.options.browser()).launch(
launchOptions);
this.playwrightContext = playwrightBrowser.newContext();

final Browser.NewContextOptions contextOptions = new Browser.NewContextOptions();
if (StringUtils.isNotBlank(this.options.recordVideoDir())) {
contextOptions.setRecordVideoDir(Paths.get(this.options.recordVideoDir()));
}
this.playwrightContext = playwrightBrowser.newContext(contextOptions);
return Collections.emptyMap();
}

Expand All @@ -69,6 +77,10 @@ private static BrowserType browser(Playwright playwright, WithPlaywright.Browser

@Override
public void stop() {
if (this.playwrightContext != null) {
this.playwrightContext.close();
this.playwrightContext = null;
}
if (playwright != null) {
playwright.close();
playwright = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
*/
double slowMo() default 0;

/**
* Enables video recording for all pages into the specified directory. If not specified videos are not recorded.
*/
String recordVideoDir() default "";

/**
* Args for use to launch the browser
*/
Expand All @@ -63,4 +68,4 @@ enum Browser {
WEBKIT
}

}
}

0 comments on commit 1014f8c

Please sign in to comment.