mirror of
https://github.com/microsoft/playwright-java.git
synced 2025-12-29 02:40:42 +00:00
remove JUnit Options getters (#1487)
This commit is contained in:
parent
de1d6a6b36
commit
70a8577f6f
@ -25,73 +25,41 @@ public class Options {
|
||||
return this;
|
||||
}
|
||||
|
||||
public BrowserType.LaunchOptions getLaunchOptions() {
|
||||
return launchOptions;
|
||||
}
|
||||
|
||||
public Options setLaunchOptions(BrowserType.LaunchOptions launchOptions) {
|
||||
this.launchOptions = launchOptions;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Browser.NewContextOptions getContextOptions() {
|
||||
return contextOptions;
|
||||
}
|
||||
|
||||
public Options setContextOptions(Browser.NewContextOptions contextOptions) {
|
||||
this.contextOptions = contextOptions;
|
||||
return this;
|
||||
}
|
||||
|
||||
public APIRequest.NewContextOptions getApiRequestOptions() {
|
||||
return apiRequestOptions;
|
||||
}
|
||||
|
||||
public Options setApiRequestOptions(APIRequest.NewContextOptions apiRequestOptions) {
|
||||
this.apiRequestOptions = apiRequestOptions;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBaseUrl() {
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
public Options setBaseUrl(String baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getBrowserName() {
|
||||
return browserName;
|
||||
}
|
||||
|
||||
public Options setBrowserName(String browserName) {
|
||||
this.browserName = browserName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDeviceName() {
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
public Options setDeviceName(String deviceName) {
|
||||
this.deviceName = deviceName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public Options setChannel(String channel) {
|
||||
this.channel = channel;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Boolean isHeadless() {
|
||||
return headless;
|
||||
}
|
||||
|
||||
public Options setHeadless(Boolean headless) {
|
||||
this.headless = headless;
|
||||
return this;
|
||||
|
||||
@ -38,7 +38,7 @@ public class APIRequestContextExtension implements ParameterResolver, BeforeEach
|
||||
|
||||
Options options = OptionsExtension.getOptions(extensionContext);
|
||||
Playwright playwright = PlaywrightExtension.getOrCreatePlaywright(extensionContext);
|
||||
apiRequestContext = playwright.request().newContext(options.getApiRequestOptions());
|
||||
apiRequestContext = playwright.request().newContext(options.apiRequestOptions);
|
||||
threadLocalAPIRequestContext.set(apiRequestContext);
|
||||
return apiRequestContext;
|
||||
}
|
||||
|
||||
@ -49,19 +49,19 @@ public class BrowserContextExtension implements ParameterResolver, AfterEachCall
|
||||
}
|
||||
|
||||
private static Browser.NewContextOptions getContextOptions(Playwright playwright, Options options) {
|
||||
Browser.NewContextOptions contextOptions = Utils.clone(options.getContextOptions());
|
||||
Browser.NewContextOptions contextOptions = Utils.clone(options.contextOptions);
|
||||
if (contextOptions == null) {
|
||||
contextOptions = new Browser.NewContextOptions();
|
||||
}
|
||||
|
||||
if (options.getBaseUrl() != null) {
|
||||
contextOptions.setBaseURL(options.getBaseUrl());
|
||||
if (options.baseUrl != null) {
|
||||
contextOptions.setBaseURL(options.baseUrl);
|
||||
}
|
||||
|
||||
if (options.getDeviceName() != null) {
|
||||
DeviceDescriptor deviceDescriptor = DeviceDescriptor.findByName(playwright, options.getDeviceName());
|
||||
if (options.deviceName != null) {
|
||||
DeviceDescriptor deviceDescriptor = DeviceDescriptor.findByName(playwright, options.deviceName);
|
||||
if (deviceDescriptor == null) {
|
||||
throw new PlaywrightException("Unknown device name: " + options.getDeviceName());
|
||||
throw new PlaywrightException("Unknown device name: " + options.deviceName);
|
||||
}
|
||||
contextOptions.userAgent = deviceDescriptor.userAgent;
|
||||
if (deviceDescriptor.viewport != null) {
|
||||
|
||||
@ -43,8 +43,8 @@ public class BrowserExtension implements ParameterResolver, AfterAllCallback {
|
||||
BrowserType.LaunchOptions launchOptions = getLaunchOptions(options);
|
||||
|
||||
BrowserType browserType = playwright.chromium();
|
||||
if (options.getBrowserName() != null) {
|
||||
browserType = getBrowserTypeForName(playwright, options.getBrowserName());
|
||||
if (options.browserName != null) {
|
||||
browserType = getBrowserTypeForName(playwright, options.browserName);
|
||||
} else if (options.deviceName != null) {
|
||||
DeviceDescriptor deviceDescriptor = DeviceDescriptor.findByName(playwright, options.deviceName);
|
||||
if (deviceDescriptor != null && deviceDescriptor.defaultBrowserType != null) {
|
||||
@ -71,17 +71,17 @@ public class BrowserExtension implements ParameterResolver, AfterAllCallback {
|
||||
}
|
||||
|
||||
private static BrowserType.LaunchOptions getLaunchOptions(Options options) {
|
||||
BrowserType.LaunchOptions launchOptions = Utils.clone(options.getLaunchOptions());
|
||||
BrowserType.LaunchOptions launchOptions = Utils.clone(options.launchOptions);
|
||||
if (launchOptions == null) {
|
||||
launchOptions = new BrowserType.LaunchOptions();
|
||||
}
|
||||
|
||||
if (options.isHeadless() != null) {
|
||||
launchOptions.setHeadless(options.isHeadless());
|
||||
if (options.headless != null) {
|
||||
launchOptions.setHeadless(options.headless);
|
||||
}
|
||||
|
||||
if (options.getChannel() != null) {
|
||||
launchOptions.setChannel(options.getChannel());
|
||||
if (options.channel != null) {
|
||||
launchOptions.setChannel(options.channel);
|
||||
}
|
||||
|
||||
return launchOptions;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user