本文整理了Java中com.gargoylesoftware.htmlunit.WebClient.setAlertHandler()
方法的一些代码示例,展示了WebClient.setAlertHandler()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.setAlertHandler()
方法的具体详情如下:
包路径:com.gargoylesoftware.htmlunit.WebClient
类名称:WebClient
方法名:setAlertHandler
[英]Sets the alert handler for this webclient.
[中]设置此webclient的警报处理程序。
代码示例来源:origin: org.seleniumhq.selenium/selenium-htmlunit-driver
HtmlUnitAlert(HtmlUnitDriver driver) {
this.driver = driver;
driver.getWebClient().setAlertHandler(this);
}
代码示例来源:origin: com.axway.ats.framework/ats-uiengine
@Override
@PublicAtsApi
public void clickOk() {
isProcessed = false;
webClient.setAlertHandler(new AlertHandler() {
@Override
public void handleAlert(
Page alertPage,
String alertText ) {
isProcessed = true;
//do nothing, by default it clicks the OK button
}
});
}
代码示例来源:origin: com.axway.ats.framework/ats-uiengine
@Override
@PublicAtsApi
public void clickOk(
final String expectedAlertText ) {
isProcessed = false;
webClient.setAlertHandler(new AlertHandler() {
@Override
public void handleAlert(
Page alertPage,
String alertText ) {
isProcessed = true;
if (!alertText.equals(expectedAlertText)) {
throw new VerificationException("The expected alert message was: '" + expectedAlertText
+ "', but actually it is: '" + alertText + "'");
}
}
});
}
代码示例来源:origin: org.juzu/juzu-core
public UserAgent(URL homeURL) {
WebClient client = new WebClient(BrowserVersion.FIREFOX_3_6);
client.setAlertHandler(new AlertHandler() {
public void handleAlert(Page page, String message) {
List<String> l = alerts.get(page);
if (l == null) {
alerts.put(page, l = new ArrayList<String>());
}
l.add(message);
}
});
//
this.alerts = new IdentityHashMap<Page, List<String>>();
this.client = client;
this.homeURL = homeURL;
}
代码示例来源:origin: juzu/juzu
public UserAgent(URL homeURL) {
WebClient client = new WebClient(BrowserVersion.FIREFOX_3_6);
client.setAlertHandler(new AlertHandler() {
public void handleAlert(Page page, String message) {
List<String> l = alerts.get(page);
if (l == null) {
alerts.put(page, l = new ArrayList<String>());
}
l.add(message);
}
});
//
this.alerts = new IdentityHashMap<Page, List<String>>();
this.client = client;
this.homeURL = homeURL;
}
代码示例来源:origin: com.atlassian.integrationtesting/atlassian-integrationtesting-lib
CompositeUiTester(ApplicationProperties applicationProperties,
Function<Login, HtmlPage> login,
Function<WebSudoLogin, HtmlPage> webSudoLogin,
Function<UiTester, Void> logout,
Function<UiTester, String> getLoggedInUser,
Function<UiTester, Boolean> isOnLogInPage,
Function<Backup, Void> restore)
{
this.applicationProperties = applicationProperties;
this.webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_11);
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.setRefreshHandler(new WaitingRefreshHandler());
webClient.setAlertHandler(new AlertHandler()
{
public void handleAlert(Page page, String message)
{
System.out.println("ALERT: " + message);
}
});
this.login = login;
this.webSudoLogin = webSudoLogin;
this.logout = logout;
this.getLoggedInUser = getLoggedInUser;
this.isOnLogInPage = isOnLogInPage;
this.restore = restore;
}
代码示例来源:origin: stapler/stapler
public void testExclude() throws Exception {
final String[] msg = new String[1];
WebClient wc = new WebClient();
wc.setAlertHandler(new AlertHandler() {
public void handleAlert(Page page, String message) {
msg[0] = message;
}
});
HtmlPage page = wc.getPage(new URL(url, "/"));
page.executeJavaScript("v.getSomeExcludedData(callback);");
Map json = (Map)JSON.parse(msg[0]);
assertTrue(json.containsKey("name"));
assertTrue(json.containsKey("description"));
assertFalse(json.containsKey("secret"));
}
代码示例来源:origin: stapler/stapler
public void testInclude() throws Exception {
final String[] msg = new String[1];
WebClient wc = new WebClient();
wc.setAlertHandler(new AlertHandler() {
public void handleAlert(Page page, String message) {
msg[0] = message;
}
});
HtmlPage page = wc.getPage(new URL(url, "/"));
page.executeJavaScript("v.getSomeIncludedData(callback);");
Map json = (Map)JSON.parse(msg[0]);
assertTrue(json.containsKey("name"));
assertFalse(json.containsKey("description"));
assertFalse(json.containsKey("secret"));
}
代码示例来源:origin: stapler/stapler
public void testExcludeList() throws Exception {
final String[] msg = new String[1];
WebClient wc = new WebClient();
wc.setAlertHandler(new AlertHandler() {
public void handleAlert(Page page, String message) {
msg[0] = message;
}
});
HtmlPage page = wc.getPage(new URL(url, "/"));
page.executeJavaScript("v.getSomeExcludedList(callback);");
Object[] json = (Object[])JSON.parse(msg[0]);
assertEquals(3, json.length);
for (Object o : json) {
Map map = (Map)o;
assertTrue(map.containsKey("name"));
assertTrue(map.containsKey("description"));
assertFalse(map.containsKey("secret"));
}
}
代码示例来源:origin: stapler/stapler
/**
* Exports an object and see if it can be reached.
*/
public void testBind() throws Exception {
final String[] msg = new String[1];
// for interactive debugging
// System.out.println(url);
// System.in.read();
WebClient wc = new WebClient();
wc.setAlertHandler(new AlertHandler() {
public void handleAlert(Page page, String message) {
msg[0] = message;
}
});
HtmlPage page = wc.getPage(new URL(url, "/"));
page.executeJavaScript("v.foo(3,'test',callback);");
assertEquals("string:test3",msg[0]);
msg[0] = null;
// test null unmarshalling and marshalling
page.executeJavaScript("v.foo(0,null,callback);");
assertEquals("object:null",msg[0]);
}
代码示例来源:origin: net.sourceforge.jwebunit/jwebunit-htmlunit-plugin
wc.setAlertHandler(new AlertHandler() {
@Override
public void handleAlert(Page page, String msg) {
代码示例来源:origin: com.vaadin.external.gwt/gwt-user
@Override
public void run() {
WebClient webClient = new WebClient(browser);
webClient.setAlertHandler(this);
webClient.setIncorrectnessListener(this);
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
代码示例来源:origin: net.wetheinter/gwt-user
@Override
public void run() {
WebClient webClient = new WebClient(browser);
webClient.setAlertHandler(this);
webClient.setIncorrectnessListener(this);
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
内容来源于网络,如有侵权,请联系作者删除!