![]() |
![]() |
selenium-server-standalone-2.42.2line #88 -> byte code offset #273 // Java source line #89 -> byte code offset #278 // Java source line #91 -> byte code offset #289 // Java source line #93 -> byte code offset #294 // Java source line #98 -> byte code offset #298 // Local variable table: // start length slot name signature // 0 300 0 this ProfilesIni // 0 300 1 appData File // 3 296 2 toReturn Map<String, File> // 14 31 3 profilesIni File // 25 242 4 isRelative boolean // 28 252 5 name String // 31 234 6 path String // 34 256 7 reader java.io.BufferedReader // 58 130 8 line String // 195 7 8 e IOException // 84 11 9 profile File // 207 46 10 localObject Object // 225 11 11 profile File // 271 11 11 profile File // 251 1 14 localIOException1 IOException // 297 1 15 localIOException2 IOException // Exception table: // from to target type // 36 192 195 java/io/IOException // 36 207 207 finally // 209 248 251 java/io/IOException // 255 294 297 java/io/IOException } protected File newProfile(String name, File appData, String path, boolean isRelative) { if ((name != null) && (path != null)) { File profileDir = isRelative ? new File(appData, path) : new File(path); return profileDir; } return null; } public FirefoxProfile getProfile(String profileName) { File profileDir = (File)profiles.get(profileName); if (profileDir == null) { return null; } File tempDir = TemporaryFilesystem.getDefaultTmpFS().createTempDir("userprofile", "copy"); try { FileHandler.copy(profileDir, tempDir); File compreg = new File(tempDir, "compreg.dat"); if ((compreg.exists()) && (!compreg.delete())) { throw new WebDriverException("Cannot delete file from copy of profile " + profileName); } } catch (IOException e) { throw new WebDriverException(e); } return new FirefoxProfile(tempDir); } protected File locateAppDataDirectory(Platform os) { File appData; File appData; if (os.is(Platform.WINDOWS)) { appData = new File(MessageFormat.format("{0}\\Mozilla\\Firefox", new Object[] { System.getenv("APPDATA") })); } else { File appData; if (os.is(Platform.MAC)) { appData = new File(MessageFormat.format("{0}/Library/Application Support/Firefox", new Object[] { System.getenv("HOME") })); } else { appData = new File(MessageFormat.format("{0}/.mozilla/firefox", new Object[] { System.getenv("HOME") })); } } if (!appData.exists()) { return null; } if (!appData.isDirectory()) { throw new WebDriverException("The discovered user firefox data directory (which normally contains the profiles) isn't a directory: " + appData.getAbsolutePath()); } return appData; } } /* Location: * Qualified Name: org.openqa.selenium.firefox.internal.ProfilesIni * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.openqa.selenium.firefox.internal; import java.io.OutputStream; import org.openqa.selenium.remote.internal.CircularOutputStream; public class Streams { public static String drainStream(OutputStream stream) { if (stream == null) { return null; } if ((stream instanceof CircularOutputStream)) { return stream.toString(); } return null; } } /* Location: * Qualified Name: org.openqa.selenium.firefox.internal.Streams * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.openqa.selenium.htmlunit; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import org.openqa.selenium.TimeoutException; import org.openqa.selenium.WebDriverException; public class AsyncScriptExecutor$AsyncScriptResult { private final CountDownLatch latch = new CountDownLatch(1); private volatile Object value = null; private volatile boolean isTimeout = false; private volatile boolean unloadDetected = false; Object waitForResult() throws InterruptedException { long startTimeNanos = System.nanoTime(); latch.await(); if (isTimeout) { long elapsedTimeNanos = System.nanoTime() - startTimeNanos; long elapsedTimeMillis = TimeUnit.NANOSECONDS.toMillis(elapsedTimeNanos); throw new TimeoutException( "Timed out waiting for async script result after " + elapsedTimeMillis + "ms"); } if (unloadDetected) { throw new WebDriverException( "Detected a page unload event; executeAsyncScript does not work across page loads"); } return value; } public void callback(Object value) { if (latch.getCount() > 0L) { this.value = value; latch.countDown(); } } public void timeout() { if (latch.getCount() > 0L) { isTimeout = true; latch.countDown(); } } public void unload() { if (latch.getCount() > 0L) { unloadDetected = true; latch.countDown(); } } } /* Location: * Qualified Name: org.openqa.selenium.htmlunit.AsyncScriptExecutor.AsyncScriptResult * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.openqa.selenium.htmlunit; import com.gargoylesoftware.htmlunit.ScriptException; import com.gargoylesoftware.htmlunit.ScriptResult; import com.gargoylesoftware.htmlunit.html.HtmlPage; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import net.sourceforge.htmlunit.corejs.javascript.Function; import net.sourceforge.htmlunit.corejs.javascript.NativeJavaObject; import org.openqa.selenium.TimeoutException; import org.openqa.selenium.WebDriverException; class AsyncScriptExecutor { private final HtmlPage page; private final long timeoutMillis; AsyncScriptExecutor(HtmlPage page, long timeoutMillis) { this.page = page; this.timeoutMillis = timeoutMillis; } public Object execute(String scriptBody, Object[] parameters) { AsyncScriptResult asyncResult = new AsyncScriptResult(); Function function = createInjectedScriptFunction(scriptBody, asyncResult); try { page.executeJavaScriptFunctionIfPossible(function, function, parameters, page.getDocumentElement()); } catch (ScriptException e) { throw new WebDriverException(e); } try { return asyncResult.waitForResult(); } catch (InterruptedException e) { throw new WebDriverException(e); } } private Function createInjectedScriptFunction(String userScript, AsyncScriptResult asyncResult) { String script = "function() { var self = this, timeoutId; var cleanUp = function() { window.clearTimeout(timeoutId); if (window.detachEvent) { window.detachEvent('onunload', catchUnload); } else { window.removeEventListener('unload', catchUnload, false); } }; var self = this, timeoutId, catchUnload = function() { cleanUp(); self.host.unload(); }; arguments = Array.prototype.slice.call(arguments, 0); arguments.push(function(value) { cleanUp(); self.host.callback(typeof value == 'undefined' ? null : value); }); if (window.attachEvent) { window.attachEvent('onunload', catchUnload); } else { window.addEventListener('unload', catchUnload, false); } (function() {" + userScript + "}).apply(null, arguments);" + " timeoutId = window.setTimeout(function() {" + " self.host.timeout();" + " }, " + timeoutMillis + ");" + "}"; ScriptResult result = page.executeJavaScript(script); Function function = (Function)result.getJavaScriptResult(); function.put("host", function, new NativeJavaObject(function, asyncResult, null)); return function; } public static class AsyncScriptResult { private final CountDownLatch latch = new CountDownLatch(1); private volatile Object value = null; private volatile boolean isTimeout = false; private volatile boolean unloadDetected = false; Object waitForResult() throws InterruptedException { long startTimeNanos = System.nanoTime(); latch.await(); if (isTimeout) { long elapsedTimeNanos = System.nanoTime() - startTimeNanos; long elapsedTimeMillis = TimeUnit.NANOSECONDS.toMillis(elapsedTimeNanos); throw new TimeoutException( "Timed out waiting for async script result after " + elapsedTimeMillis + "ms"); } if (unloadDetected) { throw new WebDriverException( "Detected a page unload event; executeAsyncScript does not work across page loads"); } return value; } public void callback(Object value) { if (latch.getCount() > 0L) { this.value = value; latch.countDown(); } } public void timeout() { if (latch.getCount() > 0L) { isTimeout = true; latch.countDown(); } } public void unload() { if (latch.getCount() > 0L) { unloadDetected = true; latch.countDown(); } } } } /* Location: * Qualified Name: org.openqa.selenium.htmlunit.AsyncScriptExecutor * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.openqa.selenium.htmlunit; import com.gargoylesoftware.htmlunit.WebWindow; import com.gargoylesoftware.htmlunit.WebWindowEvent; import com.gargoylesoftware.htmlunit.WebWindowListener; class HtmlUnitDriver$1 implements WebWindowListener { HtmlUnitDriver$1(HtmlUnitDriver paramHtmlUnitDriver) {} public void webWindowOpened(WebWindowEvent webWindowEvent) {} public void webWindowContentChanged(WebWindowEvent event) { if (event.getWebWindow() != HtmlUnitDriver.access$1(this$0)) { return; } HtmlUnitDriver.access$2(this$0, HtmlUnitDriver.access$1(this$0)); } public void webWindowClosed(WebWindowEvent event) { WebWindow curr = HtmlUnitDriver.access$1(this$0); do { if (curr == event.getWebWindow()) { HtmlUnitDriver.access$0(this$0, HtmlUnitDriver.access$1(this$0).getTopWindow()); return; } curr = curr.getParentWindow(); } while (curr != HtmlUnitDriver.access$1(this$0).getTopWindow()); } } /* Location: * Qualified Name: org.openqa.selenium.htmlunit.HtmlUnitDriver.1 * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.openqa.selenium.htmlunit; import net.sourceforge.htmlunit.corejs.javascript.Context; import net.sourceforge.htmlunit.corejs.javascript.ContextAction; import net.sourceforge.htmlunit.corejs.javascript.Scriptable; class HtmlUnitDriver$2 implements ContextAction { HtmlUnitDriver$2(HtmlUnitDriver paramHtmlUnitDriver, Object[] paramArrayOfObject1, Object[] paramArrayOfObject2, Scriptable paramScriptable) {} public Object run(Context context) { for (int i = 0; i < val$args.length; i++) { val$parameters[i] = HtmlUnitDriver.access$10(this$0, context, val$scope, val$args[i]); } return null; } } /* Location: * Qualified Name: org.openqa.selenium.htmlunit.HtmlUnitDriver.2 * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.openqa.selenium.htmlunit; import net.sourceforge.htmlunit.corejs.javascript.NativeArray; class HtmlUnitDriver$3 implements HtmlUnitDriver.JavaScriptResultsCollection { HtmlUnitDriver$3(HtmlUnitDriver paramHtmlUnitDriver, NativeArray paramNativeArray) {} public int getLength() { return (int)val$array.getLength(); } public Object item(int index) { return val$array.get(index); } } /* Location: * Qualified Name: org.openqa.selenium.htmlunit.HtmlUnitDriver.3 * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.openqa.selenium.htmlunit; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLCollection; class HtmlUnitDriver$4 implements HtmlUnitDriver.JavaScriptResultsCollection { HtmlUnitDriver$4(HtmlUnitDriver paramHtmlUnitDriver, HTMLCollection paramHTMLCollection) {} public int getLength() { return val$array.getLength(); } public Object item(int index) { return val$array.get(Integer.valueOf(index)); } } /* Location: * Qualified Name: org.openqa.selenium.htmlunit.HtmlUnitDriver.4 * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.openqa.selenium.htmlunit; import java.util.concurrent.Callable; import org.openqa.selenium.By; import org.openqa.selenium.SearchContext; import org.openqa.selenium.WebElement; class HtmlUnitDriver$5 implements Callable<WebElement> { HtmlUnitDriver$5(HtmlUnitDriver paramHtmlUnitDriver, By paramBy, SearchContext paramSearchContext) {} public WebElement call() throws Exception { return val$locator.findElement(val$context); } } /* Location: * Qualified Name: org.openqa.selenium.htmlunit.HtmlUnitDriver.5 * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.openqa.selenium.htmlunit; import com.gargoylesoftware.htmlunit.History; import com.gargoylesoftware.htmlunit.WebWindow; import com.gargoylesoftware.htmlunit.html.HtmlPage; import java.io.IOException; import java.net.SocketTimeoutException; import java.net.URL; import org.openqa.selenium.TimeoutException; import org.openqa.selenium.WebDriver.Navigation; import org.openqa.selenium.WebDriverException; class HtmlUnitDriver$HtmlUnitNavigation implements WebDriver.Navigation { private HtmlUnitDriver$HtmlUnitNavigation(HtmlUnitDriver paramHtmlUnitDriver) {} public void back() { try { this$0.getCurrentWindow().getHistory().back(); } catch (IOException e) { throw new WebDriverException(e); } } public void forward() { try { this$0.getCurrentWindow().getHistory().forward(); } catch (IOException e) { throw new WebDriverException(e); } } public void to(String url) { this$0.get(url); } public void to(URL url) { this$0.get(url); } public void refresh() { if ((this$0.lastPage() instanceof HtmlPage)) { try { ((HtmlPage)this$0.lastPage()).refresh(); } catch (SocketTimeoutException e) { throw new TimeoutException(e); } catch (IOException e) { throw new WebDriverException(e); } } } } /* Location: * Qualified Name: org.openqa.selenium.htmlunit.HtmlUnitDriver.HtmlUnitNavigation * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.openqa.selenium.htmlunit; import com.google.common.base.Function; import org.openqa.selenium.Cookie.Builder; class HtmlUnitDriver$HtmlUnitOptions$1 implements Function<com.gargoylesoftware.htmlunit.util.Cookie, org.openqa.selenium.Cookie> { HtmlUnitDriver$HtmlUnitOptions$1(HtmlUnitDriver.HtmlUnitOptions paramHtmlUnitOptions) {} public org.openqa.selenium.Cookie apply(com.gargoylesoftware.htmlunit.util.Cookie c) { return new Cookie.Builder(c.getName(), c.getValue()).domain(c.getDomain()).path(c.getPath()).expiresOn(c.getExpires()).isSecure(c.isSecure()).build(); } } /* Location: * Qualified Name: org.openqa.selenium.htmlunit.HtmlUnitDriver.HtmlUnitOptions.1 * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.openqa.selenium.htmlunit; import com.gargoylesoftware.htmlunit.CookieManager; import com.gargoylesoftware.htmlunit.Page; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.google.common.base.Function; import com.google.common.collect.Collections2; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import java.net.URL; import java.util.Set; import org.openqa.selenium.Cookie.Builder; import org.openqa.selenium.InvalidCookieDomainException; import org.openqa.selenium.UnableToSetCookieException; import org.openqa.selenium.WebDriver.ImeHandler; import org.openqa.selenium.WebDriver.Options; import org.openqa.selenium.WebDriver.Timeouts; import org.openqa.selenium.WebDriver.Window; import org.openqa.selenium.logging.Logs; class HtmlUnitDriver$HtmlUnitOptions implements WebDriver.Options { private HtmlUnitDriver$HtmlUnitOptions(HtmlUnitDriver paramHtmlUnitDriver) {} public Logs logs() { throw new UnsupportedOperationException("Driver does not support this operation."); } public void addCookie(org.openqa.selenium.Cookie cookie) { Page page = this$0.lastPage(); if (!(page instanceof HtmlPage)) { throw new UnableToSetCookieException("You may not set cookies on a page that is not HTML"); } String domain = getDomainForCookie(); verifyDomain(cookie, domain); this$0.getWebClient().getCookieManager().addCookie( new com.gargoylesoftware.htmlunit.util.Cookie(domain, cookie.getName(), cookie.getValue(), cookie.getPath(), cookie.getExpiry(), cookie.isSecure())); } private void verifyDomain(org.openqa.selenium.Cookie cookie, String expectedDomain) { String domain = cookie.getDomain(); if (domain == null) { return; } if ("".equals(domain)) { throw new InvalidCookieDomainException( "Domain must not be an empty string. Consider using null instead"); } if (domain.matches(".*[^:]:\\d+$")) { domain = domain.replaceFirst(":\\d+$", ""); } expectedDomain = "." + expectedDomain; domain = "." + domain; if (!expectedDomain.endsWith(domain)) { throw new InvalidCookieDomainException( String.format( "You may only add cookies that would be visible to the current domain: %s => %s", new Object[] { domain, expectedDomain })); } } public org.openqa.selenium.Cookie getCookieNamed(String name) { Set<org.openqa.selenium.Cookie> allCookies = getCookies(); for (org.openqa.selenium.Cookie cookie : allCookies) { if (name.equals(cookie.getName())) { return cookie; } } return null; } public void deleteCookieNamed(String name) { CookieManager cookieManager = this$0.getWebClient().getCookieManager(); URL url = HtmlUnitDriver.access$3(this$0); Set<com.gargoylesoftware.htmlunit.util.Cookie> rawCookies = cookieManager.getCookies(url); for (com.gargoylesoftware.htmlunit.util.Cookie cookie : rawCookies) { if (name.equals(cookie.getName())) { cookieManager.removeCookie(cookie); } } } public void deleteCookie(org.openqa.selenium.Cookie cookie) { this$0.getWebClient().getCookieManager().removeCookie(convertSeleniumCookieToHtmlUnit(cookie)); } public void deleteAllCookies() { this$0.getWebClient().getCookieManager().clearCookies(); } public Set<org.openqa.selenium.Cookie> getCookies() { URL url = HtmlUnitDriver.access$3(this$0); if (!url.toString().startsWith("http")) { return Sets.newHashSet(); } return ImmutableSet.copyOf(Collections2.transform( this$0.getWebClient().getCookieManager().getCookies(url), htmlUnitCookieToSeleniumCookieTransformer)); } private com.gargoylesoftware.htmlunit.util.Cookie convertSeleniumCookieToHtmlUnit(org.openqa.selenium.Cookie cookie) { return new com.gargoylesoftware.htmlunit.util.Cookie( cookie.getDomain(), cookie.getName(), cookie.getValue(), cookie.getPath(), cookie.getExpiry(), cookie.isSecure(), cookie.isHttpOnly()); } private final Function<? super com.gargoylesoftware.htmlunit.util.Cookie, org.openqa.selenium.Cookie> htmlUnitCookieToSeleniumCookieTransformer = new Function() { public org.openqa.selenium.Cookie apply(com.gargoylesoftware.htmlunit.util.Cookie c) { return new Cookie.Builder(c.getName(), c.getValue()).domain(c.getDomain()).path(c.getPath()).expiresOn(c.getExpires()).isSecure(c.isSecure()).build(); } }; private String getDomainForCookie() { URL current = HtmlUnitDriver.access$3(this$0); return current.getHost(); } public WebDriver.Timeouts timeouts() { return new HtmlUnitDriver.HtmlUnitTimeouts(this$0); } public WebDriver.ImeHandler ime() { throw new UnsupportedOperationException("Cannot input IME using HtmlUnit."); } public WebDriver.Window window() { return new HtmlUnitDriver.HtmlUnitWindow(this$0); } } /* Location: * Qualified Name: org.openqa.selenium.htmlunit.HtmlUnitDriver.HtmlUnitOptions * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.openqa.selenium.htmlunit; import com.gargoylesoftware.htmlunit.Page; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.WebWindow; import com.gargoylesoftware.htmlunit.WebWindowNotFoundException; import com.gargoylesoftware.htmlunit.html.BaseFrameElement; import com.gargoylesoftware.htmlunit.html.FrameWindow; import com.gargoylesoftware.htmlunit.html.HtmlElement; import com.gargoylesoftware.htmlunit.html.HtmlHtml; import com.gargoylesoftware.htmlunit.html.HtmlPage; import java.util.List; import org.openqa.selenium.Alert; import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.NoSuchFrameException; import org.openqa.selenium.NoSuchWindowException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver.TargetLocator; import org.openqa.selenium.WebElement; import org.openqa.selenium.internal.WrapsElement; class HtmlUnitDriver$HtmlUnitTargetLocator implements WebDriver.TargetLocator { private HtmlUnitDriver$HtmlUnitTargetLocator(HtmlUnitDriver paramHtmlUnitDriver) {} public WebDriver frame(int index) { Page page = this$0.lastPage(); if ((page instanceof HtmlPage)) { try { HtmlUnitDriver.access$0(this$0, (WebWindow)((HtmlPage)page).getFrames().get(index)); } catch (IndexOutOfBoundsException localIndexOutOfBoundsException) { throw new NoSuchFrameException("Cannot find frame: " + index); } } return this$0; } public WebDriver frame(String nameOrId) { Page page = this$0.lastPage(); if ((page instanceof HtmlPage)) { for (FrameWindow frameWindow : ((HtmlPage)page).getFrames()) { if (frameWindow.getName().equals(nameOrId)) { HtmlUnitDriver.access$0(this$0, frameWindow); return this$0; } } } try { HtmlUnitWebElement element = (HtmlUnitWebElement)this$0.findElementById(nameOrId); HtmlElement domElement = element.getElement(); if ((domElement instanceof BaseFrameElement)) { HtmlUnitDriver.access$0(this$0, ((BaseFrameElement)domElement).getEnclosedWindow()); return this$0; } } catch (NoSuchElementException localNoSuchElementException) { throw new NoSuchFrameException("Unable to locate frame with name or ID: " + nameOrId); } } public WebDriver frame(WebElement frameElement) { while ((frameElement instanceof WrapsElement)) { frameElement = ((WrapsElement)frameElement).getWrappedElement(); } HtmlUnitWebElement webElement = (HtmlUnitWebElement)frameElement; webElement.assertElementNotStale(); HtmlElement domElement = webElement.getElement(); if (!(domElement instanceof BaseFrameElement)) { throw new NoSuchFrameException(webElement.getTagName() + " is not a frame element."); } HtmlUnitDriver.access$0(this$0, ((BaseFrameElement)domElement).getEnclosedWindow()); return this$0; } public WebDriver parentFrame() { HtmlUnitDriver.access$0(this$0, HtmlUnitDriver.access$1(this$0).getParentWindow()); return this$0; } public WebDriver window(String windowId) { try { WebWindow window = this$0.getWebClient().getWebWindowByName(windowId); return finishSelecting(window); } catch (WebWindowNotFoundException localWebWindowNotFoundException) { List<WebWindow> allWindows = this$0.getWebClient().getWebWindows(); for (WebWindow current : allWindows) { WebWindow top = current.getTopWindow(); if (String.valueOf(System.identityHashCode(top)).equals(windowId)) { return finishSelecting(top); } } throw new NoSuchWindowException("Cannot find window: " + windowId); } } private WebDriver finishSelecting(WebWindow window) { this$0.getWebClient().setCurrentWindow(window); HtmlUnitDriver.access$0(this$0, window); this$0.pickWindow(); return this$0; } public WebDriver defaultContent() { HtmlUnitDriver.access$2(this$0, this$0.getCurrentWindow().getTopWindow()); return this$0; } public WebElement activeElement() { Page page = this$0.lastPage(); if ((page instanceof HtmlPage)) { HtmlElement element = ((HtmlPage)page).getFocusedElement(); if ((element == null) || ((element instanceof HtmlHtml))) { List<? extends HtmlElement> allBodies = ((HtmlPage)page).getDocumentElement().getHtmlElementsByTagName("body"); if (!allBodies.isEmpty()) { return this$0.newHtmlUnitWebElement((HtmlElement)allBodies.get(0)); } } else { return this$0.newHtmlUnitWebElement(element); } } throw new NoSuchElementException("Unable to locate element with focus or body tag"); } public Alert alert() { throw new UnsupportedOperationException("alert()"); } public WebDriver context(String name) { throw new UnsupportedOperationException("context(String)"); } } /* Location: * Qualified Name: org.openqa.selenium.htmlunit.HtmlUnitDriver.HtmlUnitTargetLocator * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.openqa.selenium.htmlunit; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.WebClientOptions; import java.util.concurrent.TimeUnit; import org.openqa.selenium.WebDriver.Timeouts; class HtmlUnitDriver$HtmlUnitTimeouts implements WebDriver.Timeouts { HtmlUnitDriver$HtmlUnitTimeouts(HtmlUnitDriver paramHtmlUnitDriver) {} public WebDriver.Timeouts implicitlyWait(long time, TimeUnit unit) { HtmlUnitDriver.access$4(this$0, TimeUnit.MILLISECONDS.convert(Math.max(0L, time), unit)); return this; } public WebDriver.Timeouts setScriptTimeout(long time, TimeUnit unit) { HtmlUnitDriver.access$5(this$0, TimeUnit.MILLISECONDS.convert(time, unit)); return this; } public WebDriver.Timeouts pageLoadTimeout(long time, TimeUnit unit) { int timeout = (int)TimeUnit.MILLISECONDS.convert(time, unit); this$0.getWebClient().getOptions().setTimeout(timeout > 0 ? timeout : 0); return this; } } /* Location: * Qualified Name: org.openqa.selenium.htmlunit.HtmlUnitDriver.HtmlUnitTimeouts * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.openqa.selenium.htmlunit; import com.gargoylesoftware.htmlunit.WebWindow; import org.openqa.selenium.Dimension; import org.openqa.selenium.Point; import org.openqa.selenium.WebDriver.Window; public class HtmlUnitDriver$HtmlUnitWindow implements WebDriver.Window { private int SCROLLBAR_WIDTH = 8; private int HEADER_HEIGHT = 150; public HtmlUnitDriver$HtmlUnitWindow(HtmlUnitDriver paramHtmlUnitDriver) {} public void setSize(Dimension targetSize) { WebWindow topWindow = this$0.getCurrentWindow().getTopWindow(); int width = targetSize.getWidth(); if (width < SCROLLBAR_WIDTH) { width = SCROLLBAR_WIDTH; } topWindow.setOuterWidth(width); topWindow.setInnerWidth(width - SCROLLBAR_WIDTH); int height = targetSize.getHeight(); if (height < HEADER_HEIGHT) { height = HEADER_HEIGHT; } topWindow.setOuterHeight(height); topWindow.setInnerHeight(height - HEADER_HEIGHT); } public void setPosition(Point targetPosition) { HtmlUnitDriver.access$6(this$0, targetPosition); } public Dimension getSize() { WebWindow topWindow = this$0.getCurrentWindow().getTopWindow(); return new Dimension(topWindow.getOuterWidth(), topWindow.getOuterHeight()); } public Point getPosition() { return HtmlUnitDriver.access$7(this$0); } public void maximize() { setSize(HtmlUnitDriver.access$8(this$0)); setPosition(new Point(0, 0)); } } /* Location: * Qualified Name: org.openqa.selenium.htmlunit.HtmlUnitDriver.HtmlUnitWindow * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.openqa.selenium.htmlunit; public abstract interface HtmlUnitDriver$JavaScriptResultsCollection { public abstract int getLength(); public abstract Object item(int paramInt); } /* Location: * Qualified Name: org.openqa.selenium.htmlunit.HtmlUnitDriver.JavaScriptResultsCollection * Java Class Version: 6 (50.0) * JD-Core Version: 0.7.1 */ package org.openqa.selenium.htmlunit; import com.gargoylesoftware.htmlunit.BrowserVersion; import com.gargoylesoftware.htmlunit.CookieManager; import com.gargoylesoftware.htmlunit.ElementNotFoundException; import com.gargoylesoftware.htmlunit.History; import com.gargoylesoftware.htmlunit.Page; import com.gargoylesoftware.htmlunit.ProxyConfig; import com.gargoylesoftware.htmlunit.ScriptResult; import com.gargoylesoftware.htmlunit.SgmlPage; import com.gargoylesoftware.htmlunit.StringWebResponse; import com.gargoylesoftware.htmlunit.TopLevelWindow; import com.gargoylesoftware.htmlunit.UnexpectedPage; import com.gargoylesoftware.htmlunit.Version; import com.gargoylesoftware.htmlunit.WaitingRefreshHandler; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.WebClientOptions; import com.gargoylesoftware.htmlunit.WebResponse; import com.gargoylesoftware.htmlunit.WebWindow; import com.gargoylesoftware.htmlunit.WebWindowEvent; import com.gargoylesoftware.htmlunit.WebWindowListener; import com.gargoylesoftware.htmlunit.WebWindowNotFoundException; import com.gargoylesoftware.htmlunit.html.BaseFrameElement; import com.gargoylesoftware.htmlunit.html.DomElement; import com.gargoylesoftware.htmlunit.html.DomNode; import com.gargoylesoftware.htmlunit.html.DomNodeList; import com.gargoylesoftware.htmlunit.html.FrameWindow; import com.gargoylesoftware.htmlunit.html.HtmlAnchor; import com.gargoylesoftware.htmlunit.html.HtmlElement; import com.gargoylesoftware.htmlunit.html.HtmlHtml; import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory; import com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine; import com.gargoylesoftware.htmlunit.javascript.host.Location; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLCollection; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement; import com.google.common.collect.Collections2; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; import com.google.common.collect.Sets; import java.io.IOException; import java.net.ConnectException; import java.net.SocketTimeoutException; import java.net.URL; import java.net.UnknownHostException; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; import net.sourceforge.htmlunit.corejs.javascript.Context; import net.sourceforge.htmlunit.corejs.javascript.ContextAction; import net.sourceforge.htmlunit.corejs.javascript.NativeArray; import net.sourceforge.htmlunit.corejs.javascript.NativeObject; import net.sourceforge.htmlunit.corejs.javascript.Scriptable; import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject; import net.sourceforge.htmlunit.corejs.javascript.Undefined; import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.Capabilities; import org.openqa.selenium.Cookie.Builder; import org.openqa.selenium.Dimension; import org.openqa.selenium.HasCapabilities; import org.openqa.selenium.InvalidCookieDomainException; import org.openqa.selenium.InvalidSelectorException; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.NoSuchFrameException; import org.openqa.selenium.NoSuchWindowException; import org.openqa.selenium.Platform; import org.openqa.selenium.Point; import org.openqa.selenium.Proxy; import org.openqa.selenium.Proxy.ProxyType; import org.openqa.selenium.SearchContext; import org.openqa.selenium.StaleElementReferenceException; import org.openqa.selenium.TimeoutException; import org.openqa.selenium.UnableToSetCookieException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver.ImeHandler; import org.openqa.selenium.WebDriver.Navigation; import org.openqa.selenium.WebDriver.Options; import org.openqa.selenium.WebDriver.TargetLocator; import org.openqa.selenium.WebDriver.Timeouts; import org.openqa.selenium.WebDriver.Window; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.HasInputDevices; import org.openqa.selenium.interactions.Keyboard; import org.openqa.selenium.interactions.Mouse; import org.openqa.selenium.internal.FindsByClassName; import org.openqa.selenium.internal.FindsByCssSelector; import org.openqa.selenium.internal.FindsById; import org.openqa.selenium.internal.FindsByLinkText; import org.openqa.selenium.internal.FindsByName; import org.openqa.selenium.internal.FindsByTagName; import org.openqa.selenium.internal.FindsByXPath; import org.openqa.selenium.internal.WrapsElement; import org.openqa.selenium.logging.Logs; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.remote.SessionNotFoundException; import org.w3c.css.sac.CSSException; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class HtmlUnitDriver implements WebDriver, JavascriptExecutor, FindsById, FindsByLinkText, FindsByXPath, FindsByName, FindsByCssSelector, FindsByTagName, FindsByClassName, HasCapabilities, HasInputDevices { private WebClient webClient; private WebWindow currentWindow; private Point windowPosition = new Point(0, 0); private Dimension initialWindowDimension; private boolean enableJavascript; private ProxyConfig proxyConfig; private long implicitWait = 0L; private long scriptTimeout = 0L; private HtmlUnitKeyboard keyboard; private HtmlUnitMouse mouse; private boolean gotPage; public static final String INVALIDXPATHERROR = "The xpath expression '%s' cannot be evaluated"; public static final String INVALIDSELECTIONERROR = "The xpath expression '%s' selected an object of type '%s' instead of a WebElement"; public HtmlUnitDriver(BrowserVersion version) { webClient = createWebClient(version); currentWindow = webClient.getCurrentWindow(); initialWindowDimension = new Dimension(currentWindow.getOuterWidth(), currentWindow.getOuterHeight()); webClient.addWebWindowListener(new WebWindowListener() { public void webWindowOpened(WebWindowEvent webWindowEvent) {} public void webWindowContentChanged(WebWindowEvent event) { if (event.getWebWindow() != currentWindow) { return; } HtmlUnitDriver.this.switchToDefaultContentOfWindow(currentWindow); } public void webWindowClosed(WebWindowEvent event) { WebWindow curr = currentWindow; do { if (curr == event.getWebWindow()) { currentWindow = currentWindow.getTopWindow(); return; } curr = curr.getParentWindow(); } while (curr != currentWindow.getTopWindow()); } }); get(webClient.getOptions().getHomePage()); gotPage = false; resetKeyboardAndMouseState(); } public HtmlUnitDriver() { this(false); } public HtmlUnitDriver(boolean enableJavascript) { this(BrowserVersion.getDefault()); setJavascriptEnabled(enableJavascript); } public HtmlUnitDriver(Capabilities capabilities) { this(determineBrowserVersion(capabilities)); setJavascriptEnabled(capabilities.isJavascriptEnabled()); setProxySettings(Proxy.extractFrom(capabilities)); } static BrowserVersion determineBrowserVersion(Capabilities capabilities) { String browserName = null; String browserVersion = null; String rawVersion = capabilities.getVersion(); String[] splitVersion = rawVersion == null ? new String[0] : rawVersion.split("-"); if (splitVersion.length > 1) { browserVersion = splitVersion[1]; browserName = splitVersion[0]; } else { browserName = capabilities.getVersion(); browserVersion = ""; } if (!"htmlunit".equals(capabilities.getBrowserName())) { browserName = capabilities.getBrowserName(); browserVersion = capabilities.getVersion(); } if ("firefox".equals(browserName)) { return BrowserVersion.FIREFOX_17; } if ("chrome".equals(browserName)) { return BrowserVersion.CHROME; } if ("internet explorer".equals(browserName)) { try { int version = Integer.parseInt(browserVersion); switch (version) { case 8: return BrowserVersion.INTERNET_EXPLORER_8; case 9: return BrowserVersion.INTERNET_EXPLORER_9; } return BrowserVersion.INTERNET_EXPLORER_11; } catch (NumberFormatException localNumberFormatException) { return BrowserVersion.INTERNET_EXPLORER_11; } } return BrowserVersion.getDefault(); } private WebClient createWebClient(BrowserVersion version) { WebClient client = newWebClient(version); WebClientOptions options = client.getOptions(); options.setHomePage(WebClient.URL_ABOUT_BLANK.toString()); options.setThrowExceptionOnFailingStatusCode(false); options.setPrintContentOnFailingStatusCode(false); options.setJavaScriptEnabled(enableJavascript); options.setRedirectEnabled(true); options.setUseInsecureSSL(true); if (proxyConfig != null) { options.setProxyConfig(proxyConfig); } client.setRefreshHandler(new WaitingRefreshHandler()); return modifyWebClient(client); } protected WebClient newWebClient(BrowserVersion version) { return new WebClient(version); } protected WebClient modifyWebClient(WebClient client) { return client; } public void setProxySettings(Proxy proxy) { if ((proxy == null) || (proxy.getProxyType() == Proxy.ProxyType.UNSPECIFIED)) { return; } switch (proxy.getProxyType()) { case DIRECT: ArrayList<String> noProxyHosts = new ArrayList(); String noProxy = proxy.getNoProxy(); if ((noProxy != null) && (!noProxy.equals(""))) { String[] hosts = noProxy.split(","); for (int i = 0; i < hosts.length; i++) { if (hosts[i].trim().length() > 0) { noProxyHosts.add(hosts[i].trim()); } } } String httpProxy = proxy.getHttpProxy(); if ((httpProxy != null) && (!httpProxy.equals(""))) { String host = httpProxy; int port = 0; int index = httpProxy.indexOf(":"); if (index != -1) { host = httpProxy.substring(0, index); port = Integer.parseInt(httpProxy.substring(index + 1)); } setHTTPProxy(host, port, noProxyHosts); } String socksProxy = proxy.getSocksProxy(); if ((socksProxy != null) && (!socksPr Further reading...For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.New!JAR listings
|