com.gargoylesoftware.htmlunit.WebClient.addWebWindowListener()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(6.5k)|赞(0)|评价(0)|浏览(252)

本文整理了Java中com.gargoylesoftware.htmlunit.WebClient.addWebWindowListener()方法的一些代码示例,展示了WebClient.addWebWindowListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.addWebWindowListener()方法的具体详情如下:
包路径:com.gargoylesoftware.htmlunit.WebClient
类名称:WebClient
方法名:addWebWindowListener

WebClient.addWebWindowListener介绍

[英]Adds a listener for WebWindowEvents. All events from all windows associated with this client will be sent to the specified listener.
[中]添加WebWindowEvents的侦听器。与此客户端关联的所有窗口中的所有事件都将发送到指定的侦听器。

代码示例

代码示例来源:origin: org.openqa.selenium.webdriver/webdriver-htmlunit

public HtmlUnitDriver(BrowserVersion version) {
   this.version = version;
   webClient = createWebClient(version);
   webClient.addWebWindowListener(new WebWindowListener() {
     private boolean waitingToLoad;

代码示例来源:origin: com.github.seykron/htmlunit-maven-plugin

/** Initializes the web client to wait for, registering opened windows and
 * listening for new windows.
 * @param theClient Web client to wait. Cannot be null.
 */
private void initialize(final WebClient theClient) {
 theClient.addWebWindowListener(webWindowListener);
 theClient.getOptions().setThrowExceptionOnScriptError(false);
 theClient.setJavaScriptErrorListener(javaScriptErrorListener);
 for (WebWindow webWindow : theClient.getWebWindows()) {
  if (!windows.contains(webWindow)
    && webWindow.getScriptObject() != null) {
   windows.add(webWindow);
  }
 }
}

代码示例来源:origin: net.disy.htmlunit/htmlunit

/**
 * Generic initialization logic used by all constructors. This method does not perform any
 * parameter validation; such validation must be handled by the constructors themselves.
 * @param browserVersion the browser version to simulate
 * @param proxyConfig the proxy configuration to use
 */
private void init(final BrowserVersion browserVersion, final ProxyConfig proxyConfig) {
  homePage_ = "http://www.gargoylesoftware.com/";
  browserVersion_ = browserVersion;
  proxyConfig_ = proxyConfig;
  try {
    scriptEngine_ = createJavaScriptEngineIfPossible(this);
  }
  catch (final NoClassDefFoundError e) {
    scriptEngine_ = null;
  }
  // The window must be constructed AFTER the script engine.
  addWebWindowListener(new CurrentWindowTracker());
  currentWindow_ = new TopLevelWindow("", this);
  fireWindowOpened(new WebWindowEvent(currentWindow_, WebWindowEvent.OPEN, null, null));
}

代码示例来源:origin: org.jenkins-ci/htmlunit

/**
 * Generic initialization logic used by all constructors. This method does not perform any
 * parameter validation; such validation must be handled by the constructors themselves.
 * @param browserVersion the browser version to simulate
 * @param proxyConfig the proxy configuration to use
 */
private void init(final BrowserVersion browserVersion, final ProxyConfig proxyConfig) {
  homePage_ = "http://www.gargoylesoftware.com/";
  browserVersion_ = browserVersion;
  proxyConfig_ = proxyConfig;
  try {
    scriptEngine_ = createJavaScriptEngineIfPossible(this);
  }
  catch (final NoClassDefFoundError e) {
    scriptEngine_ = null;
  }
  // The window must be constructed AFTER the script engine.
  addWebWindowListener(new CurrentWindowTracker());
  currentWindow_ = new TopLevelWindow("", this);
  fireWindowOpened(new WebWindowEvent(currentWindow_, WebWindowEvent.OPEN, null, null));
}

代码示例来源:origin: org.jvnet.hudson/htmlunit

/**
 * Generic initialization logic used by all constructors. This method does not perform any
 * parameter validation; such validation must be handled by the constructors themselves.
 * @param browserVersion the browser version to simulate
 * @param proxyConfig the proxy configuration to use
 */
private void init(final BrowserVersion browserVersion, final ProxyConfig proxyConfig) {
  homePage_ = "http://www.gargoylesoftware.com/";
  browserVersion_ = browserVersion;
  proxyConfig_ = proxyConfig;
  try {
    scriptEngine_ = createJavaScriptEngineIfPossible(this);
  }
  catch (final NoClassDefFoundError e) {
    scriptEngine_ = null;
  }
  // The window must be constructed AFTER the script engine.
  addWebWindowListener(new CurrentWindowTracker());
  currentWindow_ = new TopLevelWindow("", this);
  fireWindowOpened(new WebWindowEvent(currentWindow_, WebWindowEvent.OPEN, null, null));
}

代码示例来源:origin: com.github.seykron/htmlunit-maven-plugin

theClient.addWebWindowListener(new WebWindowListener() {

代码示例来源:origin: net.sourceforge.htmlunit/htmlunit

/**
 * Creates an instance that will use the specified {@link BrowserVersion} and proxy server.
 * @param browserVersion the browser version to simulate
 * @param proxyHost the server that will act as proxy or null for no proxy
 * @param proxyPort the port to use on the proxy server
 */
public WebClient(final BrowserVersion browserVersion, final String proxyHost, final int proxyPort) {
  WebAssert.notNull("browserVersion", browserVersion);
  browserVersion_ = browserVersion;
  if (proxyHost == null) {
    getOptions().setProxyConfig(new ProxyConfig());
  }
  else {
    getOptions().setProxyConfig(new ProxyConfig(proxyHost, proxyPort));
  }
  webConnection_ = new HttpWebConnection(this); // this has to be done after the browser version was set
  scriptEngine_ = new JavaScriptEngine(this);
  loadQueue_ = new ArrayList<>();
  // The window must be constructed AFTER the script engine.
  addWebWindowListener(new CurrentWindowTracker(this));
  currentWindow_ = new TopLevelWindow("", this);
  fireWindowOpened(new WebWindowEvent(currentWindow_, WebWindowEvent.OPEN, null, null));
  if (getBrowserVersion().hasFeature(JS_XML_SUPPORT_VIA_ACTIVEXOBJECT)) {
    initMSXMLActiveX();
  }
}

代码示例来源:origin: HtmlUnit/htmlunit

/**
 * Creates an instance that will use the specified {@link BrowserVersion} and proxy server.
 * @param browserVersion the browser version to simulate
 * @param proxyHost the server that will act as proxy or null for no proxy
 * @param proxyPort the port to use on the proxy server
 */
public WebClient(final BrowserVersion browserVersion, final String proxyHost, final int proxyPort) {
  WebAssert.notNull("browserVersion", browserVersion);
  browserVersion_ = browserVersion;
  if (proxyHost == null) {
    getOptions().setProxyConfig(new ProxyConfig());
  }
  else {
    getOptions().setProxyConfig(new ProxyConfig(proxyHost, proxyPort));
  }
  webConnection_ = new HttpWebConnection(this); // this has to be done after the browser version was set
  scriptEngine_ = new JavaScriptEngine(this);
  loadQueue_ = new ArrayList<>();
  // The window must be constructed AFTER the script engine.
  addWebWindowListener(new CurrentWindowTracker(this));
  currentWindow_ = new TopLevelWindow("", this);
  fireWindowOpened(new WebWindowEvent(currentWindow_, WebWindowEvent.OPEN, null, null));
  if (getBrowserVersion().hasFeature(JS_XML_SUPPORT_VIA_ACTIVEXOBJECT)) {
    initMSXMLActiveX();
  }
}

代码示例来源:origin: org.seleniumhq.selenium/selenium-htmlunit-driver

initialWindowDimension = new Dimension(currentWindow.getOuterWidth(), currentWindow.getOuterHeight());
webClient.addWebWindowListener(new WebWindowListener() {
 @Override
 public void webWindowOpened(WebWindowEvent webWindowEvent) {

代码示例来源:origin: net.sourceforge.jwebunit/jwebunit-htmlunit-plugin

wc.addWebWindowListener(new WebWindowListener() {
 @Override
 public void webWindowClosed(WebWindowEvent event) {

相关文章

WebClient类方法