Package com.thoughtworks.selenium

Examples of com.thoughtworks.selenium.SeleniumException


        LocatorHandler handler = handlerMap.get(ploc.type);
        if (handler == null)
            throw new UnsupportedOperationException("Unknown locator type: " + ploc);
        List<WebElement> elements = findElementsByLocator(handler, driver, ploc, selectedFrameLocators);
        if (elements == null)
            throw new SeleniumException("Element " + ploc + " not found", new NoSuchElementException(ploc.toString()));
        return filterElementsByOptionLocator(elements, ploc.option);
    }
View Full Code Here


                if (size > 0)
                    switchToFrame(driver, selectedFrameLocators.subList(0, size - 1));
                else
                    log.warn("The current selected frame is top level. \"" + ploc + "\" is ignored.");
            } else {
                throw new SeleniumException("Invalid \"relative\" locator argument: " + ploc.arg);
            }
            return Arrays.asList(driver.switchTo().activeElement());
        } else if (ploc.isTypeIndex()) {
            switchToFrame(driver, selectedFrameLocators);
            List<WebElement> frames = driver.findElements(By.tagName("iframe"));
            if (frames.isEmpty())
                frames = driver.findElements(By.tagName("frame"));
            int index = ploc.getIndex();
            if (index < 0 || index >= frames.size())
                throw new SeleniumException("\"index\" locator argument is out of range: " + ploc.arg);
            return Arrays.asList(frames.get(index));
        } else {
            switchToFrame(driver, selectedFrameLocators);
            return findElementsInternal(driver, ploc, selectedFrameLocators);
        }
View Full Code Here

                    switchToFrame(driver, currentFrameLocators);
                } else {
                    log.warn("The current selected frame is top level. \"" + ploc + "\" is ignored.");
                }
            } else { // neither "relative=top" nor "relative=parent"
                throw new SeleniumException("Invalid frame locator: " + ploc);
            }
        } else if (ploc.isTypeIndex()) {
            switchToFrame(driver, currentFrameLocators);
            int index = ploc.getIndex();
            try {
                driver.switchTo().frame(index);
            } catch (NoSuchFrameException e) {
                throw new SeleniumException(e);
            }
            ploc.frameIndexList.add(index);
            currentFrameLocators.add(ploc);
        } else {
            switchToFrame(driver, currentFrameLocators);
View Full Code Here

            List<WebElement> result = new ArrayList<WebElement>();
            if (index < options.size())
                result.add(options.get(index));
            return result;
        } catch (NumberFormatException e) {
            throw new SeleniumException("Invalid index: " + arg);
        }
    }
View Full Code Here

        } catch (RuntimeException e) {
            // for HtmlUnit
            if (!e.getClass().getSimpleName().contains("Script"))
                throw e;
            String message = e.getMessage().replaceFirst("\\s*\\([^()]+\\)$", "");
            throw new SeleniumException(message, e);
        }
    }
View Full Code Here

            writer.append(", storedVars];})();");
        else
            writer.append("];");
        Object result = ((JavascriptExecutor) driver).executeScript(writer.toString());
        if (!(result instanceof List))
            throw new SeleniumException(result.toString());
        List<?> list = (List<?>) result;
        switch (list.size()) {
        case 0:
            return null;
        case 1:
View Full Code Here

      Set<String> windowHandles = driver.getWindowHandles();
      windowHandles.remove(context.getInitialWindowHandle());
      if (windowHandles.size() > 0) {
        driver.switchTo().window(windowHandles.iterator().next());
      } else {
        throw new SeleniumException("Unable to find a popup window");
      }
    } else {
      selectWindow(driver, windowID);
    }
  }
View Full Code Here

        int index = Integer.parseInt(locator.substring("index=".length()));
        lastFrame.put(driver.getWindowHandle(), locator);
        driver.switchTo().frame(index);
        return;
      } catch (NumberFormatException e) {
        throw new SeleniumException(e.getMessage(), e);
      } catch (NoSuchFrameException e) {
        throw new SeleniumException(e.getMessage(), e);
      }
    }

    if (locator.startsWith("id=")) {
      locator = locator.substring("id=".length());
    } else if (locator.startsWith("name=")) {
      locator = locator.substring("name=".length());
    }

    try {
      lastFrame.put(driver.getWindowHandle(), locator);
      driver.switchTo().frame(locator);
    } catch (NoSuchFrameException e) {
      throw new SeleniumException(e.getMessage(), e);
    }
  }
View Full Code Here

      }
    }

    driver.switchTo()
        .window(current);
    throw new SeleniumException("Unable to select window with title: " + title);
  }
View Full Code Here

        return;
      }
    }
    // We couldn't find it
    driver.switchTo().window(current);
    throw new SeleniumException("Unable to select window _blank");
  }
View Full Code Here

TOP

Related Classes of com.thoughtworks.selenium.SeleniumException

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.