Search in sources :

Example 1 with TestsigmaDriver

use of com.testsigma.automator.drivers.TestsigmaDriver in project testsigma by testsigmahq.

the class DriverSessionsService method createSession.

public String createSession(DriverSessionRequest driverSessionRequest) throws Exception {
    com.testsigma.agent.dto.WebDriverSettingsDTO webDriverSettingsDTO;
    if (ExecutionLabType.Hybrid.equals(driverSessionRequest.getExecutionLabType()) && WorkspaceType.isMobileApp(driverSessionRequest.getWorkspaceType())) {
        disconnectDeviceSession(driverSessionRequest.getUniqueId());
        driverSessionRequest.setWebDriverServerUrl(new URL(mobileAutomationServer.getServerURL()));
    }
    webDriverSettingsDTO = fetchWebDriverSettings(driverSessionRequest);
    log.info("Creating a remote web driver session with settings - " + webDriverSettingsDTO);
    TestsigmaDriver testsigmaDriver = getDriverInstance(driverSessionRequest);
    List<WebDriverCapability> caps = webDriverSettingsDTO.getWebDriverCapabilities();
    addMissingTimeOutCapability(caps);
    handleLocalDevice(caps, driverSessionRequest);
    setRemoteServerURL(testsigmaDriver, driverSessionRequest, webDriverSettingsDTO);
    testsigmaDriver.setCapabilities(caps);
    RemoteWebDriver remoteWebDriver = testsigmaDriver.createSession();
    String sessionId = populateSessionIdMaps(remoteWebDriver, driverSessionRequest);
    sendMobileSessionStartedRequest(sessionId, driverSessionRequest);
    return sessionId;
}
Also used : WebDriverCapability(com.testsigma.automator.drivers.WebDriverCapability) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) TestsigmaDriver(com.testsigma.automator.drivers.TestsigmaDriver) URL(java.net.URL) WebDriverSettingsDTO(com.testsigma.agent.dto.WebDriverSettingsDTO)

Example 2 with TestsigmaDriver

use of com.testsigma.automator.drivers.TestsigmaDriver in project testsigma by testsigmahq.

the class DriverSessionsService method deleteSession.

public void deleteSession(String sessionId) throws Exception {
    log.debug("Removing session from appium server");
    RemoteWebDriver remoteWebDriver = sessionContainer.getSessionMap().get(sessionId);
    new TestsigmaDriver().deleteSession(remoteWebDriver);
    if (sessionContainer.getSessionMap().containsKey(sessionId)) {
        sessionContainer.getSessionMap().remove(sessionId);
        String deviceId = sessionContainer.getSessionToDeviceIdMap().get(sessionId);
        sessionContainer.getSessionToDeviceIdMap().remove(sessionId);
        sessionContainer.getDeviceToSessionMap().remove(deviceId);
        if (deviceContainer != null && deviceContainer.getDeviceMap().containsKey(deviceId)) {
            MobileDevice device = deviceContainer.getDevice(deviceId);
            if ((device != null) && (device.getOsName() == MobileOs.IOS)) {
                iosDeviceService.cleanupWda(device);
            } else {
                log.info("Device os is not iOS. Skipping WDA cleanup");
            }
        }
    } else {
        log.info("Session ID - " + sessionId + " doesn't exist.");
    }
}
Also used : RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) TestsigmaDriver(com.testsigma.automator.drivers.TestsigmaDriver)

Aggregations

TestsigmaDriver (com.testsigma.automator.drivers.TestsigmaDriver)2 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)2 WebDriverSettingsDTO (com.testsigma.agent.dto.WebDriverSettingsDTO)1 WebDriverCapability (com.testsigma.automator.drivers.WebDriverCapability)1 URL (java.net.URL)1