Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.BrowserVersion


      // If no browsers specified, default to Firefox 3.
      args = "FF3";
    }
    Set<BrowserVersion> browserSet = new HashSet<BrowserVersion>();
    for (String browserName : args.split(",")) {
      BrowserVersion browser = BROWSER_MAP.get(browserName);
      if (browser == null) {
        getLogger().log(
            TreeLogger.ERROR,
            "RunStyleHtmlUnit: Unknown browser " + "name " + browserName
                + ", expected browser name: one of " + BROWSER_MAP.keySet());
View Full Code Here


      // If no browsers specified, default to Firefox 3.
      args = "FF3";
    }
    Set<BrowserVersion> browserSet = new HashSet<BrowserVersion>();
    for (String browserName : args.split(",")) {
      BrowserVersion browser = BROWSER_MAP.get(browserName);
      if (browser == null) {
        getLogger().log(TreeLogger.ERROR, "RunStyleHtmlUnit: Unknown browser "
            + "name " + browserName + ", expected browser name: one of "
            + BROWSER_MAP.keySet());
        return false;
View Full Code Here

                    new Object[] { useJavaScript }, HtmlUnitDriver.class);
        }
        // set browser version
        else {
            return SecurityActions.newInstance(configuration.getImplementationClass(), new Class<?>[] { BrowserVersion.class },
                    new Object[] { new BrowserVersion(applicationName, applicationVersion, userAgent, browserVersionNumeric) },
                    HtmlUnitDriver.class);
        }
    }
View Full Code Here

   *
   */
  public WebClient createWebClient() {
    final Configuration cfg = this;
    final String strUserAgent = cfg.getUserAgent();
    final BrowserVersion browserVersion = setupBrowserVersion(fBrowser, strUserAgent);
    final WebClient webClient = setupWebClient(browserVersion);

    webClient.setTimeout(getTimeout() * 1000);

    setupHtmlParser(webClient, cfg);
View Full Code Here

    };
    webClient.setPageCreator(pageCreator);
  }

  static BrowserVersion setupBrowserVersion(final String browserName, final String strUserAgent) {
    BrowserVersion browserVersion = null;

    if (browserName != null) {
      final String browserNameLC = browserName.toLowerCase().trim();
      if ("ff2".equals(browserNameLC) || "firefox2".equals(browserNameLC))
        browserVersion = BrowserVersion.FIREFOX_2;
      else if ("ff3".equals(browserNameLC) || "firefox3".equals(browserNameLC))
        browserVersion = BrowserVersion.FIREFOX_3;
      else if ("ie6".equals(browserNameLC) || "internetexplorer6".equals(browserNameLC))
        browserVersion = BrowserVersion.INTERNET_EXPLORER_6;
      else if ("ie7".equals(browserNameLC) || "internetexplorer7".equals(browserNameLC))
        browserVersion = BrowserVersion.INTERNET_EXPLORER_7;
      else
        throw new IllegalArgumentException("Illegal browser version: >" + browserName);
    }
    if (strUserAgent != null) {
      // as long as all browser properties are not configurable from the task,
      // use a "base" browser
      final BrowserVersion baseBrowser;

      if (browserVersion != null) {
        baseBrowser = browserVersion;
      }
      else if (strUserAgent.indexOf("Gecko") != -1) {
        baseBrowser = BrowserVersion.FIREFOX_2;
      }
      else if (strUserAgent.indexOf(BrowserVersion.NETSCAPE) != -1) {
        baseBrowser = new BrowserVersion(BrowserVersion.NETSCAPE, "5.0 (Windows; en-US)",
                  "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US;rv:0.9.4.1) Gecko/20020508 Netscape6/6.2.3",
                  "1.2", 6);
      }
      else {
        baseBrowser = BrowserVersion.INTERNET_EXPLORER_6;
      }

      browserVersion = new BrowserVersion(baseBrowser.getApplicationName(),
         baseBrowser.getApplicationVersion(), strUserAgent,
         baseBrowser.getJavaScriptVersion(),
         baseBrowser.getBrowserVersionNumeric());
      LOG.info("Using browser version (" + browserVersion.getApplicationName() + ", "
         + browserVersion.getApplicationVersion() + ", " + strUserAgent + ", "
         + browserVersion.getJavaScriptVersion()
         + ", " + browserVersion.getBrowserVersionNumeric()
         + "). If the javascript support is not as expected, then it's time to go into the sources");
View Full Code Here

            log.log(Level.WARNING,
                    "Creating HtmlUnitDriver using legacy configuration. ApplicationName={0} ApplicationVersion={1} UserAgent={2} BrowserVersionNumeric={3}",
                    new Object[] { applicationName, applicationVersion, userAgent, browserVersionNumeric });

            return SecurityActions.newInstance(configuration.getImplementationClass(), new Class<?>[] { BrowserVersion.class },
                    new Object[] { new BrowserVersion(applicationName, applicationVersion, userAgent, browserVersionNumeric) },
                    HtmlUnitDriver.class);
        }
    }
View Full Code Here

      args = "FF17";
    }
    Set<BrowserVersion> browserSet = new HashSet<BrowserVersion>();
    Set<String> userAgentSet = new HashSet<String>();
    for (String browserName : args.split(",")) {
      BrowserVersion browser = BROWSER_MAP.get(browserName);
      if (browser == null) {
        getLogger().log(
            TreeLogger.ERROR,
            "RunStyleHtmlUnit: Unknown browser " + "name " + browserName
                + ", expected browser name: one of " + BROWSER_MAP.keySet());
View Full Code Here

        }

        // Let's tweak WebClient

        String headlessBrowser = System.getProperty("headlessBrowser", "INTERNET_EXPLORER_8");
        BrowserVersion browserVersion;
        if ("FIREFOX_3".equals(headlessBrowser)) {
            browserVersion = BrowserVersion.FIREFOX_3;
        } else if ("FIREFOX_3_6".equals(headlessBrowser)) {
            browserVersion = BrowserVersion.FIREFOX_3_6;
        } else if ("INTERNET_EXPLORER_6".equals(headlessBrowser)) {
View Full Code Here

  }

  private Set<BrowserVersion> getBrowserSet(String[] targetsIn) {
    Set<BrowserVersion> browserSet = new HashSet<BrowserVersion>();
    for (String browserName : targetsIn) {
      BrowserVersion browser = BROWSER_MAP.get(browserName);
      if (browser == null) {
        throw new IllegalArgumentException("Expected browser name: one of "
            + BROWSER_MAP.keySet() + ", actual name: " + browserName);
      }
      browserSet.add(browser);
View Full Code Here

      // If no browsers specified, default to Firefox 3.
      args = "FF3";
    }
    Set<BrowserVersion> browserSet = new HashSet<BrowserVersion>();
    for (String browserName : args.split(",")) {
      BrowserVersion browser = BROWSER_MAP.get(browserName);
      if (browser == null) {
        getLogger().log(
            TreeLogger.ERROR,
            "RunStyleHtmlUnit: Unknown browser " + "name " + browserName
                + ", expected browser name: one of " + BROWSER_MAP.keySet());
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.BrowserVersion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.