Example usage for org.openqa.selenium.remote RemoteWebDriver getSessionId

List of usage examples for org.openqa.selenium.remote RemoteWebDriver getSessionId

Introduction

In this page you can find the example usage for org.openqa.selenium.remote RemoteWebDriver getSessionId.

Prototype

public SessionId getSessionId() 

Source Link

Usage

From source file:org.jboss.arquillian.drone.webdriver.factory.remote.reusable.ftest.TestReusableRemoteWebDriver.java

License:Apache License

@Test
public void whenBrowserIsCreatedThenCouldBeReused(@Drone @Reusable RemoteWebDriver driver)
        throws UnableReuseSessionException {

    driver.navigate().to(SERVER_URL.toString());
    Capabilities reusedCapabilities = serializeDeserialize(driver.getCapabilities());
    SessionId reusedSessionId = new SessionId(serializeDeserialize(driver.getSessionId().toString()));

    ReusableRemoteWebDriver reusedDriver = ReusableRemoteWebDriver.fromReusedSession(HUB_URL,
            reusedCapabilities, reusedSessionId);
    reusedDriver.navigate().to(HUB_URL.toString());
}

From source file:org.jboss.arquillian.drone.webdriver.factory.remote.reusable.ftest.TestReusableRemoteWebDriver.java

License:Apache License

@Test
public void whenBrowserIsCreatedAndQuitAndTriedToReuseThenItShouldThrowException(
        @Drone @Reusable RemoteWebDriver driver) {

    driver.navigate().to(SERVER_URL.toString());
    Capabilities reusedCapabilities = serializeDeserialize(driver.getCapabilities());
    SessionId reusedSessionId = new SessionId(serializeDeserialize(driver.getSessionId().toString()));
    driver.quit();//  w w  w .j  a  v a2  s . c  o m

    try {
        ReusableRemoteWebDriver.fromReusedSession(HUB_URL, reusedCapabilities, reusedSessionId);
        fail("Original driver had quited before, so session should not be reusable");
    } catch (UnableReuseSessionException e) {
        // exception should be thrown
    }
}

From source file:org.jboss.arquillian.drone.webdriver.factory.remote.reusable.ftest.TestReusingRemoteWebDriverSession.java

License:Apache License

private void testReusableSessionId(WebDriver d) {
    RemoteWebDriver rd = (RemoteWebDriver) d;
    if (sessionId == null) {
        sessionId = rd.getSessionId();
    } else {/*from   w  ww .  ja  v a 2 s.c  o m*/
        assertEquals(sessionId, rd.getSessionId());
    }
}

From source file:org.jboss.arquillian.drone.webdriver.factory.remote.reusable.ReusableRemoteWebDriver.java

License:Apache License

private ReusableRemoteWebDriver(RemoteWebDriver remoteWebDriver) {
    super();// w  w  w. j  a v  a 2s.co m
    setCommandExecutor(remoteWebDriver.getCommandExecutor());

    reuseSession(remoteWebDriver.getSessionId(), remoteWebDriver.getCapabilities());
    try {
        checkReusability();
    } catch (UnableReuseSessionException e) {
        throw new IllegalStateException("Reusing RemoteWebDriver session unexpectedly failed", e);
    }
}

From source file:org.jboss.arquillian.drone.webdriver.factory.remote.reusable.TestReusableRemoteWebDriver.java

License:Apache License

@Test
public void whenBrowserIsCreatedThenCouldBeReused(@Drone @Reusable RemoteWebDriver driver)
        throws UnableReuseSessionException {

    driver.navigate().to(SERVER_URL.toString());

    new AugmentingEnhancer().deenhance(driver, Reusable.class); // without deenhancing we can't serialize capabilities

    Capabilities reusedCapabilities = serializeDeserialize(
            ReusedSession.createReusableCapabilities(driver.getCapabilities()));
    SessionId reusedSessionId = new SessionId(serializeDeserialize(driver.getSessionId().toString()));

    RemoteWebDriver reusedDriver = ReusableRemoteWebDriver.fromReusedSession(HUB_URL, reusedCapabilities,
            reusedSessionId);/*from  ww w. j  a v a 2  s  .  c om*/
    reusedDriver.navigate().to(HUB_URL.toString());
}

From source file:org.jboss.arquillian.drone.webdriver.factory.remote.reusable.TestReusableRemoteWebDriver.java

License:Apache License

@Test
public void whenBrowserIsCreatedAndQuitAndTriedToReuseThenItShouldThrowException(
        @Drone @Reusable RemoteWebDriver driver) {

    driver.navigate().to(SERVER_URL.toString());
    new AugmentingEnhancer().deenhance(driver, Reusable.class); // without deenhancing we can't serialize capabilities
    Capabilities reusedCapabilities = serializeDeserialize(
            ReusedSession.createReusableCapabilities(driver.getCapabilities()));
    SessionId reusedSessionId = new SessionId(serializeDeserialize(driver.getSessionId().toString()));
    driver.quit();// ww w .  j a  v a2s  . c o m

    try {
        ReusableRemoteWebDriver.fromReusedSession(HUB_URL, reusedCapabilities, reusedSessionId);
        fail("Original driver had quited before, so session should not be reusable");
    } catch (UnableReuseSessionException e) {
        // exception should be thrown
    }
}

From source file:org.jboss.arquillian.drone.webdriver.factory.RemoteWebDriverFactory.java

License:Apache License

@Override
public void destroyInstance(RemoteWebDriver instance) {
    if (instance.getSessionId() == null) {
        log.warning("The driver has been already destroyed and can't be destroyed again.");
        return;// w w  w .  j ava  2s  .  co m
    }

    InitializationParameter param = initParams.get().remove(instance.getSessionId());

    if (param != null) {
        ReusedSession session = new ReusedSession(instance.getSessionId(), instance.getCapabilities());
        sessionStore.get().store(param, session);
        persistEvent.fire(new PersistReusedSessionsEvent());
    } else {
        instance.quit();
    }

}

From source file:org.jboss.arquillian.graphene.ftest.drone.TestReusingWebDriverSession.java

License:Apache License

private void testReusableSessionId(WebDriver d) {
    RemoteWebDriver rd = (RemoteWebDriver) d;
    if (sessionId == null) {
        sessionId = rd.getSessionId();
    } else {//  ww w  .java  2  s .  c o  m
        assertEquals(sessionId, rd.getSessionId());
    }
    rd.get(HUB_URL.toExternalForm());
}