Java 类org.openqa.selenium.SessionNotCreatedException 实例源码

项目:marathonv5    文件:JavaDriverTest.java   
public void failsWhenRequestingNonCurrentPlatform() throws Throwable {
    Platform[] values = Platform.values();
    Platform otherPlatform = null;
    for (Platform platform : values) {
        if (Platform.getCurrent().is(platform)) {
            continue;
        }
        otherPlatform = platform;
        break;
    }
    DesiredCapabilities caps = new DesiredCapabilities("java", "1.0", otherPlatform);
    try {
        driver = new JavaDriver(caps, caps);
        throw new MissingException(SessionNotCreatedException.class);
    } catch (SessionNotCreatedException e) {
    }
}
项目:devtools-driver    文件:NewSessionHandler.java   
private ServerSideSession safeStart(DesiredCapabilities cap) {
  ServerSideSession session = null;
  try {
    // init session
    session = getServer().createSession(cap);
    if (session == null) {
      throw new SessionNotCreatedException(
          "The server is currently shutting down and doesn't accept new tests.");
    }

    // start session
    session.start();
    return session;
  } catch (Exception e) {
    // TODO(user): Clean this up to meet logging best practices (should not log and throw).
    logger.atSevere().withCause(e).log("Error starting the session");
    if (session != null) {
      session.stop();
    }
    throw new SessionNotCreatedException(e.getMessage(), e);
  }
}
项目:hsac-fitnesse-fixtures    文件:DriverManager.java   
public SeleniumHelper getSeleniumHelper() {
    if (helper == null) {
        DriverFactory currentFactory = getFactory();
        if (currentFactory == null) {
            throw new StopTestException("Cannot use Selenium before configuring how to start a driver (for instance using SeleniumDriverSetup)");
        } else {
            try {
                WebDriver driver = currentFactory.createDriver();
                postProcessDriver(driver);
                SeleniumHelper newHelper = createHelper(driver);
                newHelper.setWebDriver(driver, getDefaultTimeoutSeconds());
                setSeleniumHelper(newHelper);
            } catch (SessionNotCreatedException e) {
                throw new StopTestException("Unable to create selenium session using: " + currentFactory, e);
            }
        }
    }
    return helper;
}
项目:marathonv5    文件:JavaDriverTest.java   
public void failsWhenRequestingANonJavaDriver() throws Throwable {
    DesiredCapabilities caps = new DesiredCapabilities("xjava", "1.0", Platform.getCurrent());
    try {
        driver = new JavaDriver(caps, caps);
        throw new MissingException(SessionNotCreatedException.class);
    } catch (SessionNotCreatedException e) {
    }
}
项目:marathonv5    文件:JavaDriverTest.java   
public void failsWhenRequestingUnsupportedCapability() throws Throwable {
    DesiredCapabilities caps = new DesiredCapabilities("java", "1.0", Platform.getCurrent());
    caps.setCapability("rotatable", true);
    try {
        driver = new JavaDriver(caps, caps);
        throw new MissingException(SessionNotCreatedException.class);
    } catch (SessionNotCreatedException e) {
    }
}
项目:devtools-driver    文件:NewSessionHandler.java   
@Override
public Response handle() throws Exception {
  ServerSideSession session = null;
  try {
    JsonObject capsJson = getRequest().getPayload().getJsonObject("desiredCapabilities");
    session = safeStart(new DesiredCapabilities(JavaxJson.toJavaMap(capsJson)));
    if (session == null) {
      throw new SessionNotCreatedException("Failed to start session.");
    }

    Response r = new Response();
    r.setSessionId(session.getSessionId());
    r.setValue(session.getWebDriver().capabilities());
    r.setStatus(0);
    return r;
  } catch (Exception e) {
    logger.atSevere().withCause(e).log();
    if (session != null) {
      session.stop();
    }
    if (e instanceof WebDriverException) {
      throw e;
    } else {
      throw new SessionNotCreatedException(e.getMessage(), e);
    }
  }
}