fix 3: PlayWright-Tracing

This commit is contained in:
Sami 2024-10-28 09:32:29 -04:00
parent 2667cc4900
commit 4effcf0f76
3 changed files with 38 additions and 1 deletions

View File

@ -8,7 +8,7 @@
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="openjdk-23" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="openjdk-23" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -0,0 +1,37 @@
package zacksolutions;
import com.microsoft.playwright.*;
import com.microsoft.playwright.options.*;
import static com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat;
import java.nio.file.Paths;
import java.util.*;
public class AWS {
public static void main(String[] args) {
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions()
.setHeadless(false));
BrowserContext context = browser.newContext();
// Start tracing before creating / navigating a page.
context.tracing().start(new Tracing.StartOptions()
.setScreenshots(true)
.setSnapshots(true)
.setSources(true));
Page page = context.newPage();
page.navigate("https://aws.amazon.com/");
page.getByRole(AriaRole.LINK, new Page.GetByRoleOptions().setName("Sign In")).click();
page.getByLabel("Account ID (12 digits) or").click();
page.getByLabel("Account ID (12 digits) or").fill("123");
page.getByLabel("IAM username").click();
page.getByLabel("IAM username").fill("dev");
page.getByTestId("password").getByLabel("Password").click();
page.getByTestId("password").getByLabel("Password").fill("passw");
// Stop tracing and export it into a zip archive.
context.tracing().stop(new Tracing.StopOptions()
.setPath(Paths.get("trace.zip")));
}
}
}

BIN
Playright/trace.zip Normal file

Binary file not shown.