镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public static BrowserContext getOrCreateBrowserContext(ExtensionContext extensio
Browser browser = BrowserExtension.getOrCreateBrowser(extensionContext);
Browser.NewContextOptions contextOptions = getContextOptions(playwright, options);
browserContext = browser.newContext(contextOptions);
if (options.defaultTimeout != null) {
browserContext.setDefaultTimeout(options.defaultTimeout);
}
if (shouldRecordTrace(options)) {
Tracing.StartOptions startOptions = new Tracing.StartOptions().setSnapshots(true).setScreenshots(true).setTitle(extensionContext.getDisplayName());
if (System.getenv("PLAYWRIGHT_JAVA_SRC") != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public class Options {
// Custom attribute to be used in page.getByTestId(). data-testid is used by default.
public String testIdAttribute;
public Boolean ignoreHTTPSErrors;
// Default timeout applied to each injected BrowserContext.
public Double defaultTimeout;
public BrowserType.LaunchOptions launchOptions;
public Browser.NewContextOptions contextOptions;
public APIRequest.NewContextOptions apiRequestOptions;
Expand Down Expand Up @@ -131,4 +133,15 @@ public Options setIgnoreHTTPSErrors(Boolean ignoreHTTPSErrors) {
this.ignoreHTTPSErrors = ignoreHTTPSErrors;
return this;
}

/**
* Sets the default timeout for each BrowserContext created by the JUnit extension.
*
* @param defaultTimeout timeout in milliseconds
* @return this options instance
*/
public Options setDefaultTimeout(Double defaultTimeout) {
this.defaultTimeout = defaultTimeout;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public Options getOptions() {
return new Options()
.setBaseUrl(serverMap.get(TestFixtureOptions.class).EMPTY_PAGE)
.setBrowserName("webkit")
.setDefaultTimeout(10_000.0)
.setTestIdAttribute("data-my-custom-testid");
}
}
Expand Down
Loading