List of usage examples for org.openqa.selenium WebDriverException WebDriverException
public WebDriverException(Throwable cause)
From source file:com.ariatemplates.seleniumjavarobot.DebuggableChrome.java
License:Apache License
private Object sendCommand(String commandName, Object... args) { curId++;/*from w ww .j a v a 2s. c o m*/ @SuppressWarnings("unchecked") Map<String, Object> res = (Map<String, Object>) webdriver.executeAsyncScript( "executeWebdriverCommand(arguments[0], arguments[1], arguments[2], arguments[3]);", commandName, args, curId); if (((Boolean) res.get("success")).booleanValue()) { return res.get("result"); } else { throw new WebDriverException((String) res.get("result")); } }
From source file:com.cognifide.aet.worker.drivers.AetSocketLock.java
License:Apache License
/** * @inheritDoc//from w ww. j av a 2 s . co m */ @Override public void lock(long timeoutInMillis) { synchronized (syncObject) { // Calculate the 'exit time' for our wait loop. long maxWait = System.currentTimeMillis() + timeoutInMillis + ADDITIONAL_TIMEOUT_IN_MILLIS; // Attempt to acquire the lock until something goes wrong or we run out of time. do { try { if (isLockOnInetSocketAddressFree(address)) { return; } // Randomness or retry! Something from my past (Paul H) : // http://www.wattystuff.net/amateur/packet/whatispacket.htm (search for random in page) Thread.sleep((long) (DELAY_BETWEEN_SOCKET_CHECKS * Math.random())); } catch (InterruptedException | IOException e) { throw new WebDriverException(e); } } while (System.currentTimeMillis() < maxWait); throw new WebDriverException(String.format("Unable to bind to locking port %d within %d ms", address.getPort(), timeoutInMillis + ADDITIONAL_TIMEOUT_IN_MILLIS)); } }
From source file:com.cognifide.aet.worker.drivers.AetSocketLock.java
License:Apache License
@Override public void unlock() { try {/*from w ww . ja v a 2 s . c om*/ if (lockSocket.isBound()) { lockSocket.close(); } } catch (IOException e) { throw new WebDriverException(e); } }
From source file:com.elastica.driver.CustomEventFiringWebDriver.java
License:Apache License
public void setFileDetector(final FileDetector detector) { if (detector == null) { throw new WebDriverException("file detector is null"); }//from ww w . ja v a 2 s .c o m fileDetector = detector; }
From source file:com.elastica.webelements.PageObject.java
License:Apache License
private void populateAndCapturePageSnapshot() { try {//from www. jav a 2 s. c o m setTitle(driver.getTitle()); /* * IE driver will get timeout frequently when calling getText Logs: * Line 10943: INFO | jvm 1 | 2013/06/30 17:57:56 | 17:57:56.514 * INFO - Executing: [find element: By.tagName: body] at URL: * /session/2c3f9f68-d782-4162-9297-c628f31a50d2/element) Line * 10944: INFO | jvm 1 | 2013/06/30 17:57:56 | 17:57:56.561 INFO - * Done: /session/2c3f9f68-d782-4162-9297-c628f31a50d2/element Line * 10945: INFO | jvm 1 | 2013/06/30 17:57:56 | 17:57:56.561 INFO - * Executing: [get text: 6 org.openqa.selenium.support.events. * EventFiringWebDriver$EventFiringWebElement@96812584] at URL: * /session/2c3f9f68-d782-4162-9297-c628f31a50d2/element/6/text) * Line 12020: INFO | jvm 1 | 2013/06/30 18:02:12 | 18:02:12.105 * WARN - Session 2c3f9f68-d782-4162-9297-c628f31a50d2 deleted due * to in-browser timeout. Terminating driver with DeleteSession * since it does not support Killable, the driver in question does * not support selenium-server timeouts fully * * so use htmlsource to replace gettext. */ htmlSource = driver.getPageSource(); try { bodyText = driver.findElement(By.tagName("body")).getText(); } catch (StaleElementReferenceException ignore) { logger.warn("StaleElementReferenceException got in populateAndCapturePageSnapshot"); bodyText = driver.findElement(By.tagName("body")).getText(); } } catch (UnreachableBrowserException e) { // throw // UnreachableBrowserException throw new WebDriverException(e); } catch (WebDriverException e) { throw e; } capturePageSnapshot(); }
From source file:com.galenframework.page.selenium.SeleniumPage.java
License:Apache License
private List<WebElement> driverFindElements(ByChain byChain) { if (objectContext == null) { try {//from w w w . java 2 s.c o m return byChain.findElements(driver); } catch (NullPointerException e) { throw new WebDriverException(e); } catch (StaleElementReferenceException e) { throw new WebDriverException(e); } } else { return byChain.findElements(objectContext); } }
From source file:com.google.android.testing.nativedriver.common.AndroidKeys.java
License:Apache License
/** * Returns a character's corresponding Android {@code KeyEvent} code. * * @param keyCode character to get {@code KeyEvent} code for * @return integer representing {@code KeyEvent} code *//* w w w .j a v a 2s. com*/ public static int keyCodeFor(char keyCode) throws WebDriverException { // see whether char is a special key; if so, return that for (AndroidKeys key : AndroidKeys.values()) { if (key.charAt(0) == keyCode) { return key.getAndroidKeyCode(); } } // otherwise, figure out corresponding KeyEvent integer char upperCaseKey = Character.toUpperCase(keyCode); if (Character.isDigit(upperCaseKey)) { return upperCaseKey - '0' + KeyEvent.KEYCODE_0; } if (Character.isLetter(upperCaseKey)) { return upperCaseKey - 'A' + KeyEvent.KEYCODE_A; } throw new WebDriverException( "Character '" + keyCode + "' is not yet " + "supported by Android NativeDriver."); }
From source file:com.google.android.testing.nativedriver.server.AndroidNativeDriver.java
License:Apache License
/** * Takes a string that looks like a URL and performs an operation based on the * contents of the URL. Currently only starting activities is supported. * <p>//from www. j a va 2 s. com * Supported URL type follows: * <ul> * <li>{@code and-activity://<Activity class name>}<br> * start specified activity * </ul> */ @Override public void get(String url) { URI dest; try { dest = new URI(url); } catch (URISyntaxException exception) { throw new IllegalArgumentException(exception); } if (!"and-activity".equals(dest.getScheme())) { throw new WebDriverException("Unrecognized scheme in URI: " + dest.toString()); } else if (!Strings.isNullOrEmpty(dest.getPath())) { throw new WebDriverException("Unrecognized path in URI: " + dest.toString()); } Class<?> clazz; try { clazz = Class.forName(dest.getAuthority()); } catch (ClassNotFoundException exception) { throw new WebDriverException("The specified Activity class does not exist: " + dest.getAuthority(), exception); } for (NameValuePair nvp : URLEncodedUtils.parse(dest, "utf8")) { if ("id".equals(nvp.getName())) { // This is to prevent people from recycling the same URL they got from // getCurrentUrl() and expecting to return to an arbitrary running // activity. It is not supported in the Android user interface so we // don't expose this functionality. throw new WebDriverException("Moving to the specified activity is not supported."); } } startActivity(clazz); }
From source file:com.google.android.testing.nativedriver.server.AndroidNativeDriver.java
License:Apache License
private Activity checkHasCurrentActivity() { Activity activity = context.getActivities().current(); if (activity == null) { throw new WebDriverException("Current focused activity does not exist."); }/*from w w w .j a v a2 s .c om*/ return activity; }
From source file:com.google.android.testing.nativedriver.server.AndroidNativeDriver.java
License:Apache License
@Override public Object executeScript(String action, Object... args) { String result = ""; if (action.equals("systeminfo")) { result += "{'BOARD':'" + android.os.Build.BOARD + "','"; result += "BOOTLOADER':'" + android.os.Build.BOOTLOADER + "','"; result += "CPU_ABI':'" + android.os.Build.CPU_ABI + "','"; result += "CPU_ABI2':'" + android.os.Build.CPU_ABI2 + "','"; result += "HARDWARE':'" + android.os.Build.HARDWARE + "'}"; return result; }/*from www .j a v a 2 s. com*/ if (action.equals("getscreeninfo")) return getscreeninfo(); if (action.equals("fling")) return fling(args[0], args[1]); try { if (action.equals("swipe")) return swipe(args[0], args[1], args[2], args[3]); if (action.equals("tap")) return tap(args[0], args[1]); if (action.equals("taphold")) return tapaction(args[0], args[1], MotionEvent.ACTION_DOWN); if (action.equals("tapcancel")) return tapaction(args[0], args[1], MotionEvent.ACTION_CANCEL); if (action.equals("tapmoveto")) return tapaction(args[0], args[1], MotionEvent.ACTION_MOVE); if (action.equals("taprelease")) return tapaction(args[0], args[1], MotionEvent.ACTION_UP); if (action.equals("tapscroll")) return tapaction(args[0], args[1], MotionEvent.ACTION_SCROLL); } catch (Exception e) { throw new WebDriverException("You can only tap parts of your app." + " Hitting the notification-bar or onscreen keyboard causes INJECT_EVENT error: " + e.toString()); } return result; }