Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(junit): Added ignoreHttpsErrors option #1500

Merged
merged 1 commit into from
Feb 27, 2024
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 @@ -13,6 +13,7 @@ public class Options {
public String deviceName;
// Custom attribute to be used in page.getByTestId(). data-testid is used by default.
public String testIdAttribute;
public Boolean ignoreHTTPSErrors;
public BrowserType.LaunchOptions launchOptions;
public Browser.NewContextOptions contextOptions;
public APIRequest.NewContextOptions apiRequestOptions;
Expand Down Expand Up @@ -67,4 +68,9 @@ public Options setHeadless(Boolean headless) {
this.headless = headless;
return this;
}

public Options setIgnoreHTTPSErrors(Boolean ignoreHTTPSErrors) {
this.ignoreHTTPSErrors = ignoreHTTPSErrors;
return this;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.microsoft.playwright.junit.impl;

import com.microsoft.playwright.APIRequest;
import com.microsoft.playwright.APIRequestContext;
import com.microsoft.playwright.Playwright;
import com.microsoft.playwright.impl.Utils;
import com.microsoft.playwright.junit.Options;
import org.junit.jupiter.api.extension.*;

Expand Down Expand Up @@ -38,8 +40,20 @@ static APIRequestContext getOrCreateAPIRequestContext(ExtensionContext extension

Options options = OptionsExtension.getOptions(extensionContext);
Playwright playwright = PlaywrightExtension.getOrCreatePlaywright(extensionContext);
apiRequestContext = playwright.request().newContext(options.apiRequestOptions);
apiRequestContext = playwright.request().newContext(getContextOptions(options));
threadLocalAPIRequestContext.set(apiRequestContext);
return apiRequestContext;
}

private static APIRequest.NewContextOptions getContextOptions(Options options) {
APIRequest.NewContextOptions contextOptions = Utils.clone(options.apiRequestOptions);
if(contextOptions == null) {
contextOptions = new APIRequest.NewContextOptions();
}

if(options.ignoreHTTPSErrors != null) {
contextOptions.ignoreHTTPSErrors = options.ignoreHTTPSErrors;
}
return contextOptions;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ private static Browser.NewContextOptions getContextOptions(Playwright playwright
contextOptions.hasTouch = deviceDescriptor.hasTouch;
}

if(options.ignoreHTTPSErrors != null) {
contextOptions.setIgnoreHTTPSErrors(options.ignoreHTTPSErrors);
}

return contextOptions;
}
}
Loading