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")));
    }
  }
}
