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 @@ -5,7 +5,7 @@
public class BrowserFactory {

public IBrowser createBrowser() {
return switch (BrowserName.fromString(WebPortalConstants.BROWSER)) {
return switch (BrowserName.fromConfigValue(WebPortalConstants.BROWSER)) {
case FIREFOX -> new FirefoxBrowser();
case WEBKIT -> new WebkitBrowser();
case MS_EDGE -> new MsEdgeBrowser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class BrowserManager implements IBrowserManager<Page> {

@Override
public Page getBrowserPage(Playwright playwright) {
Objects.requireNonNull(playwright, "Playwright instance is null in Browser Manager!");
boolean isHeadless = "headless".equals(WebPortalConstants.RUN_MODE);
BrowserContext browserContext = new BrowserFactory().createBrowser().createSession(playwright, isHeadless);
Objects.requireNonNull(browserContext, "Playwright Browser Context is null!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

@Getter
@AllArgsConstructor
Expand All @@ -17,7 +18,8 @@ public enum BrowserName {

private final String browserType;

public static BrowserName fromString(String browserName) {
public static BrowserName fromConfigValue(String browserName) {
Objects.requireNonNull(browserName, "Browser name cannot be null");
return Arrays.stream(BrowserName.values())
.filter(browserType -> browserType.getBrowserType().equalsIgnoreCase(browserName))
.findFirst().orElseThrow(() -> new WebUtilsException("Unknown browser: " + browserName));
Expand Down