fix: Interfaces and Abstract classes
This commit is contained in:
@@ -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")));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package zacksolutions;
|
||||
|
||||
import com.microsoft.playwright.*;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* LocatorsTest
|
||||
*/
|
||||
public class LocatorsTest {
|
||||
|
||||
@Test
|
||||
public void locatorsCount(){
|
||||
Playwright playwright = Playwright.create();
|
||||
Browser browser = playwright.firefox().launch(new BrowserType.LaunchOptions().setHeadless(false));
|
||||
BrowserContext browserContext = browser.newContext();
|
||||
Page page = browserContext.newPage();
|
||||
page.navigate("https://gitea.zacksolutions.dev/");
|
||||
Locator locatorSignin = page.locator("text = Explore");
|
||||
locatorSignin.click();
|
||||
page.locator("text = Users").click();
|
||||
Locator users = page.locator("div[class*='flex-item-title']");
|
||||
System.out.println(users.last().textContent());
|
||||
System.out.println(users.first().textContent());
|
||||
for (int i = 0; i <users.count(); i++) {
|
||||
System.out.println(users.nth(i).textContent());
|
||||
}
|
||||
browser.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package zacksolutions;
|
||||
|
||||
import com.microsoft.playwright.*;
|
||||
import org.testng.annotations.AfterTest;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class TextSelectorTest {
|
||||
Playwright playwright;
|
||||
Browser browser;
|
||||
Page page;
|
||||
@BeforeTest
|
||||
public void setUp(){
|
||||
playwright = Playwright.create();
|
||||
browser = playwright.firefox().launch(new BrowserType.LaunchOptions().setHeadless(false));
|
||||
page = browser.newPage();
|
||||
}
|
||||
@Test
|
||||
public void browserLaunch() {
|
||||
page.navigate("https://amazon.com");
|
||||
System.out.println(page.title());
|
||||
Locator linkCount = page.locator("text=Amazon");
|
||||
System.out.println(linkCount.count());
|
||||
for (int i = 0; i < linkCount.count(); i++) {
|
||||
String text = linkCount.nth(i).textContent();
|
||||
if(text.contains("Science")){
|
||||
System.out.println(text);
|
||||
linkCount.nth(i).click();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@AfterTest
|
||||
public void tearDown() {
|
||||
/*
|
||||
browser.close();
|
||||
playwright.close();
|
||||
*/
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user