fix 5: PlayWright-bestPractice
This commit is contained in:
parent
8dd167d3ed
commit
2235e1bb69
Binary file not shown.
|
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 54 KiB |
@ -3,21 +3,33 @@ package zacksolutions;
|
|||||||
import com.microsoft.playwright.Browser;
|
import com.microsoft.playwright.Browser;
|
||||||
import com.microsoft.playwright.Page;
|
import com.microsoft.playwright.Page;
|
||||||
import com.microsoft.playwright.Playwright;
|
import com.microsoft.playwright.Playwright;
|
||||||
|
import org.testng.annotations.AfterTest;
|
||||||
|
import org.testng.annotations.BeforeTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
public class BrowserLaunchTest {
|
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
|
@Test
|
||||||
public void browserLaunch() {
|
public void browserLaunch() {
|
||||||
try (Playwright playwright = Playwright.create()) {
|
|
||||||
Browser browser = playwright.chromium().launch();
|
|
||||||
Page page = browser.newPage();
|
|
||||||
page.navigate("https://zenful.cloud");
|
page.navigate("https://zenful.cloud");
|
||||||
System.out.println(page.title());
|
System.out.println(page.title());
|
||||||
page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("photo.png")));
|
page.screenshot(new Page.ScreenshotOptions().setPath(Paths.get("photo.png")));
|
||||||
page.type("input[id='message']", "4 8 15 16 23 42");
|
page.type("input[id='message']", "1 2 3 viva l'Algerie");
|
||||||
page.click("button");
|
page.click("button");
|
||||||
}
|
}
|
||||||
|
@AfterTest
|
||||||
|
public void tearDown() {
|
||||||
|
browser.close();
|
||||||
|
playwright.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user