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

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

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

WebClient.getBrowserVersion介绍

[英]Returns the current browser version.
[中]返回当前浏览器版本。

代码示例

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

/**
 * Creates a new instance of HtmlUnitContextFactory.
 *
 * @param webClient the web client using this factory
 */
public HtmlUnitContextFactory(final WebClient webClient) {
  webClient_ = webClient;
  browserVersion_ = webClient.getBrowserVersion();
  errorReporter_ = new StrictErrorReporter();
}

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

/**
 * Creates a new HTTP web connection instance.
 * @param webClient the WebClient that is using this connection
 */
public HttpWebConnection(final WebClient webClient) {
  webClient_ = webClient;
  htmlUnitCookieSpecProvider_ = new HtmlUnitCookieSpecProvider(webClient.getBrowserVersion());
  usedOptions_ = new WebClientOptions();
}

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

/**
 * Creates a new instance of HtmlUnitContextFactory.
 *
 * @param webClient the web client using this factory
 */
public HtmlUnitContextFactory(final WebClient webClient) {
  WebAssert.notNull("webClient", webClient);
  webClient_ = webClient;
  browserVersion_ = webClient.getBrowserVersion();
  errorReporter_ = new StrictErrorReporter();
}

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

/**
 * Creates a new instance of HtmlUnitContextFactory.
 *
 * @param webClient the web client using this factory
 */
public HtmlUnitContextFactory(final WebClient webClient) {
  WebAssert.notNull("webClient", webClient);
  webClient_ = webClient;
  browserVersion_ = webClient.getBrowserVersion();
  errorReporter_ = new StrictErrorReporter();
}

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

private void initMSXMLActiveX() {
  msxmlActiveXObjectFactory_ = new MSXMLActiveXObjectFactory();
  // TODO [IE] initialize in #init or in #initialize?
  try {
    msxmlActiveXObjectFactory_.init(getBrowserVersion());
  }
  catch (final Exception e) {
    LOG.error("Exception while initializing MSXML ActiveX for the page", e);
    throw new ScriptException(null, e); // BUG: null is not useful.
  }
}

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

/**
 * Creates an instance for the specified {@link WebClient}.
 *
 * @param webClient the client that will own this engine
 */
public JavaScriptEngine(final WebClient webClient) {
  webClient_ = webClient;
  contextFactory_ = new HtmlUnitContextFactory(webClient);
  initTransientFields();
  jsConfig_ = JavaScriptConfiguration.getInstance(webClient.getBrowserVersion());
}

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

/**
 * Gets the browser version currently used.
 * @return the browser version
 */
public BrowserVersion getBrowserVersion() {
  final DomNode node = getDomNodeOrNull();
  if (node != null) {
    return node.getPage().getWebClient().getBrowserVersion();
  }
  return getWindow().getWebWindow().getWebClient().getBrowserVersion();
}

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

/**
 * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br>
 *
 * Helper for a common call sequence.
 * @param feature the feature to check
 * @return {@code true} if the currently emulated browser has this feature.
 */
public boolean hasFeature(final BrowserVersionFeatures feature) {
  return getPage().getWebClient().getBrowserVersion().hasFeature(feature);
}

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

/**
   * {@inheritDoc}
   */
  @Override
  public DisplayStyle getDefaultStyleDisplay() {
    if (getPage().getWebClient().getBrowserVersion().hasFeature(SLOT_CONTENTS)) {
      return DisplayStyle.CONTENTS;
    }
    return DisplayStyle.INLINE;
  }
}

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

/**
 * Gets the browser version currently used.
 * @return the browser version
 */
protected BrowserVersion getBrowserVersion() {
  final DomNode node = getDomNodeOrNull();
  if (node != null) {
    return node.getPage().getWebClient().getBrowserVersion();
  }
  return getWindow().getWebWindow().getWebClient().getBrowserVersion();
}

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

/**
 * Adds the headers that are sent with every request to the specified {@link WebRequestSettings} instance.
 * @param wrs the <tt>WebRequestSettings</tt> instance to modify
 */
private void addDefaultHeaders(final WebRequestSettings wrs) {
  // Add standard HtmlUnit headers.
  wrs.setAdditionalHeader("Accept", "*/*");
  wrs.setAdditionalHeader("Accept-Language", getBrowserVersion().getBrowserLanguage());
  // Add user-specified headers last so that they can override HtmlUnit defaults.
  wrs.getAdditionalHeaders().putAll(requestHeaders_);
}

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

/** {@inheritDoc} */
public void comment(final char[] ch, final int start, final int length) {
  handleCharacters();
  final String data = String.valueOf(ch, start, length);
  if (!data.startsWith("[CDATA") || !page_.getWebClient().getBrowserVersion().isIE()) {
    final DomComment comment = new DomComment(page_, data);
    currentNode_.appendChild(comment);
  }
}

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

/**
 * Adds the headers that are sent with every request to the specified {@link WebRequestSettings} instance.
 * @param wrs the <tt>WebRequestSettings</tt> instance to modify
 */
private void addDefaultHeaders(final WebRequestSettings wrs) {
  // Add standard HtmlUnit headers.
  wrs.setAdditionalHeader("Accept", "*/*");
  wrs.setAdditionalHeader("Accept-Language", getBrowserVersion().getBrowserLanguage());
  // Add user-specified headers last so that they can override HtmlUnit defaults.
  wrs.getAdditionalHeaders().putAll(requestHeaders_);
}

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

/** {@inheritDoc} */
public void comment(final char[] ch, final int start, final int length) {
  handleCharacters();
  final String data = String.valueOf(ch, start, length);
  if (!data.startsWith("[CDATA") || !page_.getWebClient().getBrowserVersion().isIE()) {
    final DomComment comment = new DomComment(page_, data);
    currentNode_.appendChild(comment);
  }
}

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

/**
   * {@inheritDoc}
   */
  @Override
  public boolean handles(final Event event) {
    if (MouseEvent.TYPE_MOUSE_OVER.equals(event.getType())
        && getPage().getWebClient().getBrowserVersion().hasFeature(EVENT_ONMOUSEOVER_FOR_DISABLED_OPTION)) {
      return true;
    }
    return super.handles(event);
  }
}

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

/**
 * {@inheritDoc}
 */
@Override
public Page mouseOver(final boolean shiftKey, final boolean ctrlKey, final boolean altKey, final int button) {
  final SgmlPage page = getPage();
  if (page.getWebClient().getBrowserVersion().hasFeature(EVENT_ONMOUSEOVER_NEVER_FOR_SELECT_OPTION)) {
    return page;
  }
  return super.mouseOver(shiftKey, ctrlKey, altKey, button);
}

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

/**
 * {@inheritDoc}
 * @see SubmittableElement#setDefaultChecked(boolean)
 */
@Override
public void setDefaultChecked(final boolean defaultChecked) {
  defaultCheckedState_ = defaultChecked;
  if (getPage().getWebClient().getBrowserVersion().isFirefox()) {
    setChecked(defaultChecked);
  }
}

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

/**
 * {@inheritDoc}
 * @see SubmittableElement#setDefaultChecked(boolean)
 */
@Override
public void setDefaultChecked(final boolean defaultChecked) {
  defaultCheckedState_ = defaultChecked;
  if (getPage().getWebClient().getBrowserVersion().isFirefox()) {
    setChecked(defaultChecked);
  }
}

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

/**
 * {@inheritDoc} Also sets the value attribute when emulating Netscape browsers.
 * @see SubmittableElement#setDefaultValue(String)
 * @see HtmlFileInput#setDefaultValue(String)
 */
public void setDefaultValue(final String defaultValue) {
  final boolean modifyValue = getPage().getWebClient().getBrowserVersion().isFirefox();
  setDefaultValue(defaultValue, modifyValue);
}

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

private Worker(final Context cx, final Window owningWindow, final String url) throws Exception {
  setParentScope(owningWindow);
  setPrototype(getPrototype(getClass()));
  final WebClient webClient = getWindow().getWebWindow().getWebClient();
  workerScope_ = new DedicatedWorkerGlobalScope(owningWindow, cx, webClient.getBrowserVersion(), this);
  workerScope_.loadAndExecute(url, null);
}

相关文章

WebClient类方法