Skip to content

Commit

Permalink
Allow Playwright in Runtime module
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Oct 25, 2024
1 parent 86cfcbd commit a43548e
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
*/
package io.quarkiverse.playwright.it;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
Expand All @@ -34,8 +38,12 @@ public class PlaywrightResource {
public String hello() {
String pageTitle = "Hello playwright";
final BrowserType.LaunchOptions launchOptions = new BrowserType.LaunchOptions()
.setHeadless(true);
try (Playwright playwright = Playwright.create()) {
.setHeadless(true)
.setChromiumSandbox(false)
.setChannel("")
.setArgs(List.of("--disable-gpu"));
final Map<String, String> env = new HashMap<>(System.getenv());
try (Playwright playwright = Playwright.create(new Playwright.CreateOptions().setEnv(env))) {
try (Browser browser = playwright.chromium().launch(launchOptions)) {
Page page = browser.newPage();
page.navigate("https://playwright.dev");
Expand All @@ -44,4 +52,4 @@ public String hello() {
}
return pageTitle;
}
}
}

0 comments on commit a43548e

Please sign in to comment.