Skip to content

Commit

Permalink
[Temp] Test screenshot without headless
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangdat committed Aug 6, 2024
1 parent 9cf25f5 commit 281d527
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
15 changes: 13 additions & 2 deletions tmail_integration_test/src/main/java/com/tmail/base/TestBase.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.tmail.base;

import java.io.IOException;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Properties;
import java.util.stream.Stream;
Expand All @@ -15,10 +16,12 @@
import org.junit.jupiter.params.provider.MethodSource;

import com.microsoft.playwright.Browser;
import com.microsoft.playwright.Browser.NewContextOptions;
import com.microsoft.playwright.BrowserContext;
import com.microsoft.playwright.BrowserType;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
import com.microsoft.playwright.Tracing;

@ExtendWith(CustomParameterResolver.class)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
Expand Down Expand Up @@ -55,13 +58,21 @@ public void setUp(SupportedPlatform supportedPlatform) {
case FIREFOX -> playwright.firefox().launch(new BrowserType.LaunchOptions().setHeadless(runHeadlessTest));
default -> throw new UnsupportedPlatformException();
};
browserContext = browser.newContext(
new Browser.NewContextOptions().setViewportSize(1920, 1080));

NewContextOptions contextOptions = new Browser.NewContextOptions()
.setViewportSize(1920, 1080);
browserContext = browser.newContext(contextOptions);
browserContext.tracing().start(new Tracing.StartOptions()
.setScreenshots(true)
.setSnapshots(true));

page = browserContext.newPage();
}

@AfterEach
public void tearDown() {
browserContext.tracing().stop(new Tracing.StopOptions()
.setPath(Paths.get("trace.zip")));
page.close();
browserContext.close();
browser.close();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.tmail.scenarios;

import java.nio.file.Path;
import com.microsoft.playwright.Page;
import com.tmail.base.BaseScenario;
import com.tmail.robots.BasicAuthLoginRobot;
Expand Down Expand Up @@ -28,8 +29,10 @@ public void execute(Page page) {
loginRobot.enterUsername(username);
loginRobot.enterPassword(password);
loginRobot.clickLogin();

mailboxDashboardRobot.waitUntilExactLabelIsVisible("Compose");

page.screenshot(new Page.ScreenshotOptions().setPath(Path.of("screenshot2.png")));
}

}

0 comments on commit 281d527

Please sign in to comment.