Java Code Examples for com.gargoylesoftware.htmlunit.BrowserVersion.FIREFOX_38

The following are Jave code examples for showing how to use FIREFOX_38 of the com.gargoylesoftware.htmlunit.BrowserVersion class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Project-D2L   File: D2LHook.java   View Source Code Vote up 6 votes
public List<LockerObject> getLocker(boolean previewLink) {
	List<LockerObject> list = new ArrayList<>();
	try {
		WebClient webClient = new WebClient(BrowserVersion.FIREFOX_38);
		webClient.setCookieManager(cookieManager);

		HtmlPage page = webClient.getPage("https://pdsb.elearningontario.ca/d2l/lms/locker/locker.d2l?ou=8340");

		for (Object object : page.getByXPath("//a")) {
			DomElement de = (DomElement) object;
			if (de.asXml().toString().contains("/d2l/common/viewFile.d2lfile/Database/")) {
				if (!previewLink) {
					list.add(new LockerObject(de.getAttribute("title").replace("Open ", ""),  "https://pdsb.elearningontario.ca" + de.getAttribute("href").replace("&display=1", "")));
				} else {
					list.add(new LockerObject(de.getAttribute("title").replace("Open ", ""),  "https://pdsb.elearningontario.ca" + de.getAttribute("href")));

				}
			}
		}

		webClient.close();
	} catch (Exception e) {
		e.printStackTrace();
	}
	return list;
}
 
Example 2
Project: Project-D2L   File: D2LHook.java   View Source Code Vote up 6 votes
public List<NotificationObject> getNotifications(String ID) throws InvaildCourseException {
	List<NotificationObject> list = new ArrayList<>();
	try {
		WebClient webClient = new WebClient(BrowserVersion.FIREFOX_38);
		webClient.setCookieManager(cookieManager);

		UnexpectedPage page = webClient.getPage("https://pdsb.elearningontario.ca/d2l/MiniBar/" + ID + "/ActivityFeed/GetAlerts?Category=1&_d2l_prc%24headingLevel=2&_d2l_prc%24scope=&_d2l_prc%24hasActiveForm=false&isXhr=true&requestId=2");
		NotificationFormater notificationFormater = new NotificationFormater(page.getWebResponse().getContentAsString());
		
		webClient.close();
		
		for (Object object: notificationFormater.getNotifications()) {
			DomElement de = (DomElement) object;
			String[] split = de.asText().split("\\n");
			
			list.add(new NotificationObject(split[0].trim(), split[1].trim(), split[2].trim()));
		}
	} catch (Exception e) {
		throw new InvaildCourseException("Invaild Course ID");
	}
	
	return list;
}
 
Example 3
Project: jClipCorn   File: HTTPUtilities.java   View Source Code Vote up 6 votes
public static String getJavascriptHTML(String urlToRead, int jsTimeout) {
	//Otherwise we will get flooded with log warnings -.-
	java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(java.util.logging.Level.OFF);

	try (WebClient webClient = new WebClient(BrowserVersion.FIREFOX_38)) {
		webClient.getOptions().setJavaScriptEnabled(true);
		webClient.getOptions().setThrowExceptionOnFailingStatusCode(true);
		webClient.getOptions().setThrowExceptionOnScriptError(false);

		HtmlPage page = webClient.getPage(urlToRead);

		webClient.waitForBackgroundJavaScript(jsTimeout);

		return page.asXml();
	} catch (FailingHttpStatusCodeException | IOException e) {
		CCLog.addError(LocaleBundle.getFormattedString("LogMessage.CouldNotGetHTML", urlToRead), e);
		return "";
	}
}
 
Example 4
Project: weixinmp4j   File: WeixinmpWebSession.java   View Source Code Vote up 5 votes
private void initial() {
	this.webClient = new WebClient(BrowserVersion.FIREFOX_38);
	//this.webClient.getOptions().setProxyConfig(new ProxyConfig("cn-proxy.jp.oracle.com", 80));
	this.webClient.getCookieManager().setCookiesEnabled(true);//must enabled cookies
	this.webClient.getOptions().setJavaScriptEnabled(false);
	this.webClient.getOptions().setCssEnabled(false);
	this.webClient.getOptions().setThrowExceptionOnScriptError(false);
	this.webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
	this.webClient.getOptions().setTimeout(35000);
}
 
Example 5
Project: seauto   File: AbstractConfigurableDriverProvider.java   View Source Code Vote up 5 votes
/**
 * Default implementation of getting a local HTMLUnit Driver
 * 
 * @return {@link WebDriver} for HTMLUnit
 */
protected WebDriver getHtmlUnitWebDriver()
{
  // Set to firefox 24 to emulate a friendly javascript engine
  HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_38);
  driver.setJavascriptEnabled(true);
  return driver;
}
 
Example 6
Project: Project-D2L   File: D2LHook.java   View Source Code Vote up 5 votes
public List<ContentObject> getCourseContent(String ID) throws InvaildCourseException {
	List<ContentObject> list = new ArrayList<>();
	try {
		WebClient webClient = new WebClient(BrowserVersion.FIREFOX_38);
		webClient.setCookieManager(cookieManager);

		HtmlPage page = webClient.getPage("https://pdsb.elearningontario.ca/d2l/le/content/" + ID + "/Home");

		for (Object object : page.getByXPath("//li[@class='d2l-le-TreeAccordionItem d2l-le-TreeAccordionItem-Root']")) {
			DomElement de = (DomElement) object;
			if (de.getId().contains("D2L_LE_Content_TreeBrowser_D2L.LE.Content.ContentObject.ModuleCO-")) {
				String[] split = de.asText().split("\\n");
				List<String> ob = new ArrayList<>();

				for (int i = 1; i < split.length; i++) {
					ob.add(split[i]);
				}

				list.add(new ContentObject(split[0], ob));
			}
		}
		webClient.close();
	} catch (Exception e) {
		throw new InvaildCourseException("Invaild Course ID");
	}
	return list;
}
 
Example 7
Project: redsniff   File: SeleniumTesterFactory.java   View Source Code Vote up 5 votes
@SuppressWarnings("deprecation")
    private BrowserVersion getHtmlUnitBrowserVersion() {
		if (htmlUnitBrowserVersion.equals("FIREFOX_38"))
			return BrowserVersion.FIREFOX_38;
//		else if(htmlUnitBrowserVersion.equals("FIREFOX_10"))
//			return BrowserVersion.FIREFOX_10;
//		else if(htmlUnitBrowserVersion.equals("FIREFOX_17"))
//            return BrowserVersion.FIREFOX_17;
		else if(htmlUnitBrowserVersion.equals("CHROME"))
            return BrowserVersion.CHROME;
		else if(htmlUnitBrowserVersion.equals("INTERNET_EXPLORER_8"))
			return BrowserVersion.INTERNET_EXPLORER_8;
		else
			return BrowserVersion.getDefault();
	}
 
Example 8
Project: Camel   File: LinkedInOAuthRequestFilter.java   View Source Code Vote up 4 votes
@SuppressWarnings("deprecation")
public LinkedInOAuthRequestFilter(OAuthParams oAuthParams, Map<String, Object> httpParams,
                                  boolean lazyAuth, String[] enabledProtocols) {

    this.oAuthParams = oAuthParams;
    this.oAuthToken = null;

    // create HtmlUnit client
    webClient = new WebClient(BrowserVersion.FIREFOX_38);
    final WebClientOptions options = webClient.getOptions();
    options.setRedirectEnabled(true);
    options.setJavaScriptEnabled(false);
    options.setThrowExceptionOnFailingStatusCode(true);
    options.setThrowExceptionOnScriptError(true);
    options.setPrintContentOnFailingStatusCode(LOG.isDebugEnabled());
    options.setSSLClientProtocols(enabledProtocols);

    // add HTTP proxy if set
    if (httpParams != null && httpParams.get(ConnRoutePNames.DEFAULT_PROXY) != null) {
        final HttpHost proxyHost = (HttpHost) httpParams.get(ConnRoutePNames.DEFAULT_PROXY);
        final Boolean socksProxy = (Boolean) httpParams.get("http.route.socks-proxy");
        final ProxyConfig proxyConfig = new ProxyConfig(proxyHost.getHostName(), proxyHost.getPort(),
            socksProxy != null ? socksProxy : false);
        options.setProxyConfig(proxyConfig);
    }

    // disable default gzip compression, as error pages are sent with no compression and htmlunit doesn't negotiate
    new WebConnectionWrapper(webClient) {
        @Override
        public WebResponse getResponse(WebRequest request) throws IOException {
            request.setAdditionalHeader(HttpHeaders.ACCEPT_ENCODING, "identity");
            return super.getResponse(request);
        }
    };

    if (!lazyAuth) {
        try {
            updateOAuthToken();
        } catch (IOException e) {
            throw new IllegalArgumentException(
                String.format("Error authorizing user %s: %s", oAuthParams.getUserName(), e.getMessage()), e);
        }
    }
}
 
Example 9
Project: redsniff   File: CSVTable.java   View Source Code Vote up 4 votes
public CSVTable(File csvFile) {
    this.csvFile = csvFile;
    if(!csvFile.exists())
        throw new AssertionError(csvFile.getAbsolutePath() + " does not exist");
    csvTester = new RedsniffWebDriverTester(new HtmlUnitDriver(BrowserVersion.FIREFOX_38));
}