};
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");