package zacksolutions;

import com.microsoft.playwright.Browser;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import java.nio.file.Paths;

public class BrowserLaunchTest {
  private Playwright playwright;
  private Browser browser;
  private Page page;
  @BeforeTest
  public void setUp(){
    playwright = Playwright.create();
    browser = playwright.chromium().launch();
    page = browser.newPage();
  }
  @Test
  public void browserLaunch() {
      page.navigate("https://zenful.cloud");
      System.out.println(page.title());
      page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("photo.png")));
      page.type("input[id='message']", "1 2 3 viva l'Algerie");
      page.click("button");
    }
  @AfterTest
  public void tearDown() {
    browser.close();
    playwright.close();
  }
}
