import java.util.*;
import java.util.zip.*;
import java.util.List;
import java.util.regex.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import java.util.concurrent.locks.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.table.*;
import java.io.*;
import java.net.*;
import java.lang.reflect.*;
import java.lang.ref.*;
import java.lang.management.*;
import java.security.*;
import java.security.spec.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.imageio.*;
import java.math.*;
import com.microsoft.playwright.*;
import java.text.NumberFormat;
import static x30_pkg.x30_util.DynamicObject;
class main {
static class GazelleSiteTester implements AutoCloseable {
PlaywrightAndBrowser playwright;
String site = "https://empty.gazelle.rocks";
Scorer scorer = new Scorer();
void init() {
if (playwright == null) playwright = playwrightWithChromium();
}
abstract class Tester {
Page page;
void assertPageContainsText(String text) {
assertNotNull(scorer, text, page.querySelector("text=" + text));
}
void openSite() {
init();
page = playwrightOpenPage(playwright.browser, page, site);
}
void fill(Object... __) {
for (Map.Entry extends Object, ? extends Object> __0 : _entrySet( paramsToObjectMap(__)))
{ Object key = __0.getKey(); Object val = __0.getValue(); page.fill("[name=" + key + "]", str(val)); }
}
}
class TestRegistration extends Tester {
String user = "testuser" + random(1000000);
String pw = "pw" + random(1000000);
String contact = "dummy contact";
public void run() {
openSite();
page.click("text=Register as new user");
fill("user", user, "f_pw" , pw, "pw2" , pw, "contact", contact);
page.click("[type=submit]:has-text(\"Register\")");
assertPageContainsText(dollarFormat("User $user created", "user", user));
}
}
class LogIn extends Tester {
String user;
String pw;
double delay = 3.0;
public void run() {
openSite();
page.fill("[name=user]", user);
page.fill("[name=pw]", pw);
page.click("[type=submit]:has-text(\"Log in\")");
sleepSeconds(delay);
//page.waitForLoadState();
/*page.waitForNavigation(() -> {
page.click([[[type=submit]:has-text("Log in")]]);
});*/
assertPageContainsText("[user " + user + "]");
assertPageContainsText("BEA Objects");
}
}
LogIn registerAndLogIn() {
TestRegistration reg = new TestRegistration();
reg.run();
LogIn logIn = new LogIn();
copyFields(reg, logIn, "user", "pw", "page");
logIn.run();
return logIn;
}
public void close() { { cleanUp(playwright); playwright = null; } }
public String toString() { return "Tested " + site + ": " + scorer; }
}
// Note: Playwright is not thread-safe.
// However, you can create multiple Playwright instances and
// use each in a separate thread.
// playwright 1.14.0
static PlaywrightAndBrowser playwrightWithChromium() {
Playwright playwright = tempPlaywright();
var browser = playwright.chromium().launch();
return new PlaywrightAndBrowser(playwright, browser);
}
static A assertNotNull(A a) {
assertTrue(a != null);
return a;
}
static A assertNotNull(String msg, A a) {
assertTrue(msg, a != null);
return a;
}
static A assertNotNull(Scorer scorer, String msg, A a) {
if (scorer == null) return assertNotNull(msg, a);
if (a == null) {
print("BAD - " + msg + " is null: " + a);
scorer.add(false);
} else {
print("OK, " + msg + " not null: " + a);
scorer.add(true);
}
return a;
}
static Page playwrightOpenPage(Playwright playwright, String url) {
Page page = playwrightChromium(playwright).newPage();
page.navigate(url);
return page;
}
static Page playwrightOpenPage(Browser browser, String url) { return playwrightOpenPage(browser, null, url); }
static Page playwrightOpenPage(Browser browser, Page page, String url) {
if (page == null)
page = browser.newPage();
long _startTime_0 = sysNow();
page.navigate(url);
done2_always("navigate", _startTime_0);
return page;
}
static Set> _entrySet(Map map) {
return map == null ? Collections.EMPTY_SET : map.entrySet();
}
static Map