Search in sources :

Example 1 with DriverSessionDTO

use of com.testsigma.agent.dto.DriverSessionDTO in project testsigma by testsigmahq.

the class DriverSessionsController method createSession.

/**
 * Create a remote web driver session using selenium/appium
 *
 * @param driverSessionRequest
 * @return created remote web driver sessionId
 * @throws Exception
 */
@PostMapping
@ResponseBody
public DriverSessionDTO createSession(@RequestBody DriverSessionRequest driverSessionRequest) throws Exception {
    log.debug("Creating a remote web driver session for - " + driverSessionRequest.getUniqueId() + " ( " + driverSessionRequest + ") ");
    if (driverSessionRequest.getMobileSessionId() != null) {
        try {
            String sessionId = driverSessionsService.createSession(driverSessionRequest);
            DriverSessionDTO driverSessionDTO = new DriverSessionDTO();
            driverSessionDTO.setSessionId(sessionId);
            driverSessionDTO.setHostname(AgentService.getComputerName());
            return driverSessionDTO;
        } catch (IOException e) {
            log.error(e.getMessage(), e);
            throw new AutomatorException(e.getMessage(), e);
        }
    } else {
        throw new TestsigmaException("Failed creating driver session: mobileSessionId is NULL");
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) TestsigmaException(com.testsigma.agent.exception.TestsigmaException) IOException(java.io.IOException) DriverSessionDTO(com.testsigma.agent.dto.DriverSessionDTO)

Example 2 with DriverSessionDTO

use of com.testsigma.agent.dto.DriverSessionDTO in project testsigma by testsigmahq.

the class DriverSessionsController method getSession.

/**
 * get the status of a remote web driver session
 *
 * @param sessionId
 * @return session status
 * @throws Exception
 */
@GetMapping(value = "/{sessionId}")
public DriverSessionDTO getSession(@PathVariable("sessionId") String sessionId) throws Exception {
    log.debug("Getting remote web driver session details with session Id- " + sessionId);
    String sessionStatus = driverSessionsService.getSession(sessionId);
    DriverSessionDTO driverSessionDTO = new DriverSessionDTO();
    driverSessionDTO.setSessionId(sessionId);
    driverSessionDTO.setStatus(sessionStatus);
    return driverSessionDTO;
}
Also used : DriverSessionDTO(com.testsigma.agent.dto.DriverSessionDTO)

Aggregations

DriverSessionDTO (com.testsigma.agent.dto.DriverSessionDTO)2 TestsigmaException (com.testsigma.agent.exception.TestsigmaException)1 AutomatorException (com.testsigma.automator.exceptions.AutomatorException)1 IOException (java.io.IOException)1