本文整理汇总了Java中com.gargoylesoftware.htmlunit.BrowserVersion.FIREFOX_38属性的典型用法代码示例。如果您正苦于以下问题:Java BrowserVersion.FIREFOX_38属性的具体用法?Java BrowserVersion.FIREFOX_38怎么用?Java BrowserVersion.FIREFOX_38使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.gargoylesoftware.htmlunit.BrowserVersion
的用法示例。
在下文中一共展示了BrowserVersion.FIREFOX_38属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLocker
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;
}
示例2: getNotifications
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;
}
示例3: getJavascriptHTML
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 "";
}
}
示例4: initial
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);
}
示例5: getHtmlUnitWebDriver
/**
* 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;
}
示例6: getCourseContent
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;
}
示例7: getHtmlUnitBrowserVersion
@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();
}
示例8: LinkedInOAuthRequestFilter
@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);
}
}
}
示例9: CSVTable
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));
}