当前位置: 首页>>代码示例>>Java>>正文


Java BrowserVersion.FIREFOX_24属性代码示例

本文整理汇总了Java中com.gargoylesoftware.htmlunit.BrowserVersion.FIREFOX_24属性的典型用法代码示例。如果您正苦于以下问题:Java BrowserVersion.FIREFOX_24属性的具体用法?Java BrowserVersion.FIREFOX_24怎么用?Java BrowserVersion.FIREFOX_24使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.gargoylesoftware.htmlunit.BrowserVersion的用法示例。


在下文中一共展示了BrowserVersion.FIREFOX_24属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupClient

private WebClient setupClient(final String username, final String password) {
  final WebClient client = new WebClient(BrowserVersion.FIREFOX_24);
  final WebClientOptions options = client.getOptions();
  DefaultCredentialsProvider credentials = new DefaultCredentialsProvider();
  credentials.addCredentials(username, password);
  client.setCredentialsProvider(credentials);
  options.setRedirectEnabled(true);
  options.setThrowExceptionOnFailingStatusCode(true);
  client.addWebWindowListener(new ValidateOnContentChange());
  client.getCookieManager().setCookiesEnabled(false);

  // Try to log only "interesting" things:
  // Don't log errors we can't fix due to browser bugs etc.
  client.setIncorrectnessListener(new SuppressingIncorrectnessListener());

  return client;
}
 
开发者ID:CoreFiling,项目名称:reviki,代码行数:17,代码来源:WebTestSupport.java

示例2: getAnimeImageUrl

/**
 * Returns the Url of image for the animeId provided. The file type extension is not included.
 * @param animeId
 * @return null if not found
 * @throws FailingHttpStatusCodeException
 * @throws MalformedURLException
 * @throws IOException
 */
public static String getAnimeImageUrl(int animeId) throws FailingHttpStatusCodeException, MalformedURLException, IOException{
	String theReturn = null;
	final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_24);
	webClient.getOptions().setThrowExceptionOnScriptError(false);//Will give alot of errors
	new IgnoreRandomJScripts(webClient);
	java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(java.util.logging.Level.SEVERE);//to ignore those errors
	try{
		Page page = webClient.getPage("http://myanimelist.net/anime.php?id="+animeId);
		if(page.isHtmlPage()){
			Pattern p = Pattern.compile("http://cdn.myanimelist.net/images/anime/([0-9]+)/([0-9]+).jpg");
			Matcher m = p.matcher(page.getWebResponse().getContentAsString());
			if(m.find()){
				if(m.groupCount() == 2){
					theReturn = "http://cdn.myanimelist.net/images/anime/"+m.group(1)+"/"+m.group(2);
				}
			}
		}
	}
	catch(com.gargoylesoftware.htmlunit.ScriptException e){}
	webClient.closeAllWindows();
	java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(java.util.logging.Level.ALL);
	return theReturn;
}
 
开发者ID:apocist,项目名称:MALSignatureDesigner,代码行数:31,代码来源:Http.java

示例3: downloadImage

/**
 * Downloads and saves Jpeg from url and stores as file
 * @param url
 * @param saveLoc
 * @return true on success
 * @throws FailingHttpStatusCodeException
 * @throws MalformedURLException
 * @throws IOException
 */
public static boolean downloadImage(String url, String saveLoc) throws FailingHttpStatusCodeException, MalformedURLException, IOException{
	if(url != null && saveLoc != null){
		if(!url.isEmpty() && !saveLoc.isEmpty()){
			final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_24);
			Page page = webClient.getPage(url);
			webClient.closeAllWindows();
			if(page.getWebResponse().getContentType().equals("image/jpeg")){//grabbed the xml file
				InputStream in = page.getWebResponse().getContentAsStream();
				OutputStream out; out = new FileOutputStream(new File(System.getProperty("user.dir") + saveLoc));
				IOUtils.copy(in,out);
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:apocist,项目名称:MALSignatureDesigner,代码行数:25,代码来源:Http.java

示例4: getAnimeList

/**
	 * Retrieves the anime history for inputted user
	 * @param username
	 * @param rssType rw
	 * @return XML as String
	 * @throws FailingHttpStatusCodeException
	 * @throws MalformedURLException
	 * @throws IOException
	 */
	public static String getAnimeList(String username, String rssType) throws FailingHttpStatusCodeException, MalformedURLException, IOException{
	final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_24);
	Page page = webClient.getPage("http://myanimelist.net/rss.php?type="+rssType+"&u="+username);
	//System.out.println(page.getWebResponse().getContentAsString());
	String content = page.getWebResponse().getContentAsString();
	webClient.closeAllWindows();
	if(content.startsWith("<?xml") && content.length() > 350){//grabbed the xml file
		return content;
	}
	return null;
}
 
开发者ID:apocist,项目名称:MALSignatureDesigner,代码行数:20,代码来源:Http.java

示例5: commonHtmlUnitDriverStepHelper

@Bean
@Scope(value = "prototype")
public CommonHtmlUnitDriverStepHelper commonHtmlUnitDriverStepHelper() throws MalformedURLException {

    return new CommonHtmlUnitDriverStepHelper(new HtmlUnitDriver(BrowserVersion.FIREFOX_24), webappUrl(), populatePageUrl());
}
 
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:6,代码来源:GuiStoriesContext.java

示例6: htmlUnitDriver

@SuppressWarnings("unused")
private static WebDriver htmlUnitDriver() {
	HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_24);
	driver.setJavascriptEnabled(true);
	return driver;
}
 
开发者ID:caelum,项目名称:mamute,代码行数:6,代码来源:AcceptanceTestBase.java


注:本文中的com.gargoylesoftware.htmlunit.BrowserVersion.FIREFOX_24属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。