本文整理了Java中com.gargoylesoftware.htmlunit.WebClient.getCache()
方法的一些代码示例,展示了WebClient.getCache()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.getCache()
方法的具体详情如下:
包路径:com.gargoylesoftware.htmlunit.WebClient
类名称:WebClient
方法名:getCache
[英]Gets the cache currently being used.
[中]获取当前正在使用的缓存。
代码示例来源:origin: stackoverflow.com
WebDriver driver = new HtmlUnitDriver() {
@Override
protected WebClient getWebClient() {
WebClient c = super.getWebClient();
c.getCache().setMaxSize(0);
return c;
}
};
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
/**
* {@inheritDoc}
*/
@Override
public void cleanUp() {
if (getWebClient().getCache().getCachedResponse(webResponse_.getWebRequest()) == null) {
webResponse_.cleanUp();
}
}
代码示例来源:origin: HtmlUnit/htmlunit
/**
* {@inheritDoc}
*/
@Override
public void cleanUp() {
if (getWebClient().getCache().getCachedResponse(webResponse_.getWebRequest()) == null) {
webResponse_.cleanUp();
}
}
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
final WebResponse fromCache = getCache().getCachedResponse(webRequest);
if (fromCache != null) {
return new WebResponseFromCache(fromCache, webRequest);
final WebResponseData responseData = new WebResponseData(content, 200, "OK", compiledHeaders);
final WebResponse webResponse = new WebResponse(responseData, webRequest, 0);
getCache().cacheIfPossible(webRequest, webResponse, null);
return webResponse;
代码示例来源:origin: HtmlUnit/htmlunit
final WebResponse fromCache = getCache().getCachedResponse(webRequest);
if (fromCache != null) {
return new WebResponseFromCache(fromCache, webRequest);
final WebResponseData responseData = new WebResponseData(content, 200, "OK", compiledHeaders);
final WebResponse webResponse = new WebResponse(responseData, webRequest, 0);
getCache().cacheIfPossible(webRequest, webResponse, null);
return webResponse;
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
/**
* Cleans up this page.
*/
@Override
public void cleanUp() {
if (getEnclosingWindow().getWebClient().getCache().getCachedResponse(webResponse_.getWebRequest()) == null) {
webResponse_.cleanUp();
}
}
代码示例来源:origin: HtmlUnit/htmlunit
/**
* Cleans up this page.
*/
@Override
public void cleanUp() {
if (getEnclosingWindow().getWebClient().getCache().getCachedResponse(webResponse_.getWebRequest()) == null) {
webResponse_.cleanUp();
}
}
代码示例来源:origin: stackoverflow.com
try (final WebClient webClient = new WebClient(BrowserVersion.CHROME)) {
// disable caching
webClient.getCache().setMaxSize(0);
// Get the first page
final HtmlPage page1 = webClient.getPage(url);
final HtmlForm form = page1.getFormByName(formName);
final HtmlTextInput taxCodeTextField = form.getInputByName(taxCodeTextFieldName);
HtmlCheckBoxInput checkboxInput = form.getInputByName(checkboxInputName);
taxCodeTextField.type(taxCode);
checkboxInput.click();
//wait a little
Thread.sleep(2000);
//get the main page
HtmlPage page2 = (HtmlPage) webClient.getTopLevelWindows().get(0).getEnclosedPage();
HtmlSubmitInput confirmButton = page2.getFormByName(formName).getInputByName(confirmButtonName);
final HtmlPage page3 = confirmButton.click();
System.out.println(page3.asText());
}
代码示例来源:origin: com.gwtplatform/gwtp-crawler-service
WebClient webClient = webClientProvider.get();
webClient.getCache().clear();
webClient.getOptions().setCssEnabled(false);
webClient.getOptions().setJavaScriptEnabled(true);
代码示例来源:origin: ArcBees/GWTP
WebClient webClient = webClientProvider.get();
webClient.getCache().clear();
webClient.getOptions().setCssEnabled(false);
webClient.getOptions().setJavaScriptEnabled(true);
代码示例来源:origin: org.jvnet.hudson/htmlunit
final Cache cache = client.getCache();
final Object fromCache = cache.getCachedObject(request);
if (fromCache != null && fromCache instanceof CSSStyleSheet) {
代码示例来源:origin: net.disy.htmlunit/htmlunit
final Cache cache = client.getCache();
代码示例来源:origin: org.jenkins-ci/htmlunit
final Cache cache = client.getCache();
final Object fromCache = cache.getCachedObject(request);
if (fromCache != null && fromCache instanceof CSSStyleSheet) {
代码示例来源:origin: net.disy.htmlunit/htmlunit
final Cache cache = client.getCache();
final Object fromCache = cache.getCachedObject(request);
if (fromCache != null && fromCache instanceof CSSStyleSheet) {
代码示例来源:origin: org.jvnet.hudson/htmlunit
final Cache cache = client.getCache();
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
/**
* Gets the associated sheet.
* @see <a href="http://www.xulplanet.com/references/objref/HTMLStyleElement.html">Mozilla doc</a>
* @return the sheet
*/
@JsxGetter
public CSSStyleSheet getSheet() {
if (sheet_ != null) {
return sheet_;
}
final HtmlStyle style = (HtmlStyle) getDomNodeOrDie();
final String css = style.getTextContent();
final Cache cache = getWindow().getWebWindow().getWebClient().getCache();
final org.w3c.dom.css.CSSStyleSheet cached = cache.getCachedStyleSheet(css);
final String uri = getDomNodeOrDie().getPage().getWebResponse().getWebRequest()
.getUrl().toExternalForm();
if (cached != null) {
sheet_ = new CSSStyleSheet(this, cached, uri);
}
else {
final InputSource source = new InputSource(new StringReader(css));
sheet_ = new CSSStyleSheet(this, source, uri);
cache.cache(css, sheet_.getWrappedSheet());
}
return sheet_;
}
代码示例来源:origin: org.jvnet.hudson/htmlunit
/**
* Gets the associated sheet.
* @see <a href="http://www.xulplanet.com/references/objref/HTMLStyleElement.html">Mozilla doc</a>
* @return the sheet
*/
public Stylesheet jsxGet_sheet() {
if (sheet_ != null) {
return sheet_;
}
String css = "";
final HtmlStyle style = (HtmlStyle) getDomNodeOrDie();
if (style.getFirstChild() != null) {
css = style.getFirstChild().asText();
}
final Cache cache = getWindow().getWebWindow().getWebClient().getCache();
final CSSStyleSheet cached = cache.getCachedStyleSheet(css);
final String uri = getDomNodeOrDie().getPage().getWebResponse().getRequestSettings()
.getUrl().toExternalForm();
if (cached != null) {
sheet_ = new Stylesheet(this, cached, uri);
}
else {
final InputSource source = new InputSource(new StringReader(css));
sheet_ = new Stylesheet(this, source, uri);
cache.cache(css, sheet_.getWrappedSheet());
}
return sheet_;
}
代码示例来源:origin: HtmlUnit/htmlunit
/**
* Gets the associated sheet.
* @see <a href="http://www.xulplanet.com/references/objref/HTMLStyleElement.html">Mozilla doc</a>
* @return the sheet
*/
@JsxGetter
public CSSStyleSheet getSheet() {
if (sheet_ != null) {
return sheet_;
}
final HtmlStyle style = (HtmlStyle) getDomNodeOrDie();
final String css = style.getTextContent();
final Cache cache = getWindow().getWebWindow().getWebClient().getCache();
final CSSStyleSheetImpl cached = cache.getCachedStyleSheet(css);
final String uri = getDomNodeOrDie().getPage().getWebResponse().getWebRequest()
.getUrl().toExternalForm();
if (cached != null) {
sheet_ = new CSSStyleSheet(this, cached, uri);
}
else {
final InputSource source = new InputSource(new StringReader(css));
sheet_ = new CSSStyleSheet(this, source, uri);
cache.cache(css, sheet_.getWrappedSheet());
}
return sheet_;
}
代码示例来源:origin: org.jenkins-ci/htmlunit
/**
* Gets the associated sheet.
* @see <a href="http://www.xulplanet.com/references/objref/HTMLStyleElement.html">Mozilla doc</a>
* @return the sheet
*/
public Stylesheet jsxGet_sheet() {
if (sheet_ != null) {
return sheet_;
}
String css = "";
final HtmlStyle style = (HtmlStyle) getDomNodeOrDie();
if (style.getFirstChild() != null) {
css = style.getFirstChild().asText();
}
final Cache cache = getWindow().getWebWindow().getWebClient().getCache();
final CSSStyleSheet cached = cache.getCachedStyleSheet(css);
final String uri = getDomNodeOrDie().getPage().getWebResponse().getRequestSettings()
.getUrl().toExternalForm();
if (cached != null) {
sheet_ = new Stylesheet(this, cached, uri);
}
else {
final InputSource source = new InputSource(new StringReader(css));
sheet_ = new Stylesheet(this, source, uri);
cache.cache(css, sheet_.getWrappedSheet());
}
return sheet_;
}
代码示例来源:origin: net.disy.htmlunit/htmlunit
/**
* Gets the associated sheet.
* @see <a href="http://www.xulplanet.com/references/objref/HTMLStyleElement.html">Mozilla doc</a>
* @return the sheet
*/
public Stylesheet jsxGet_sheet() {
if (sheet_ != null) {
return sheet_;
}
String css = "";
final HtmlStyle style = (HtmlStyle) getDomNodeOrDie();
if (style.getFirstChild() != null) {
css = style.getFirstChild().asText();
}
final Cache cache = getWindow().getWebWindow().getWebClient().getCache();
final CSSStyleSheet cached = cache.getCachedStyleSheet(css);
final String uri = getDomNodeOrDie().getPage().getWebResponse().getRequestSettings()
.getUrl().toExternalForm();
if (cached != null) {
sheet_ = new Stylesheet(this, cached, uri);
}
else {
final InputSource source = new InputSource(new StringReader(css));
sheet_ = new Stylesheet(this, source, uri);
cache.cache(css, sheet_.getWrappedSheet());
}
return sheet_;
}
内容来源于网络,如有侵权,请联系作者删除!