Search in sources :

Example 11 with TestsigmaException

use of com.testsigma.agent.exception.TestsigmaException 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 12 with TestsigmaException

use of com.testsigma.agent.exception.TestsigmaException in project testsigma by testsigmahq.

the class AndroidDeviceListener method removeDeviceListenerCallback.

public void removeDeviceListenerCallback() throws TestsigmaException {
    try {
        if (agentConfig.getRegistered().equals(Boolean.FALSE)) {
            log.debug("Skipping agent devices listener callback de-registration since agent is not registered...");
            return;
        }
        log.debug("De-Registering agent device listener callbacks...");
        AndroidDebugBridge.removeDeviceChangeListener(this);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new TestsigmaException(e.getMessage(), e);
    }
}
Also used : TestsigmaException(com.testsigma.agent.exception.TestsigmaException) NativeBridgeException(com.testsigma.agent.exception.NativeBridgeException) TestsigmaException(com.testsigma.agent.exception.TestsigmaException) AdbCommandExecutionException(com.testsigma.agent.exception.AdbCommandExecutionException)

Example 13 with TestsigmaException

use of com.testsigma.agent.exception.TestsigmaException in project testsigma by testsigmahq.

the class WdaService method installWdaToDevice.

public void installWdaToDevice(MobileDevice device) throws TestsigmaException {
    File downloadedWdaFile = null;
    try {
        IosDeviceCommandExecutor iosDeviceCommandExecutor = new IosDeviceCommandExecutor();
        log.info("Installing WDA on device - " + device.getUniqueId());
        String wdaPresignedUrl = fetchWdaUrl(device);
        downloadedWdaFile = File.createTempFile("wda_", ".ipa");
        FileUtils.copyURLToFile(new URL(wdaPresignedUrl), downloadedWdaFile, (60 * 1000), (60 * 1000));
        log.info("Downloaded WDA to local file - " + downloadedWdaFile.getAbsolutePath());
        Process p = iosDeviceCommandExecutor.runDeviceCommand(new String[] { "-u", device.getUniqueId(), "install", downloadedWdaFile.getAbsolutePath() });
        String devicePropertiesJsonString = iosDeviceCommandExecutor.getProcessStreamResponse(p);
        log.info("Output from installing WDA file on the device - " + devicePropertiesJsonString);
        if (devicePropertiesJsonString.contains("ApplicationVerificationFailed")) {
            throw new TestsigmaException("Failed to install WDA on device - " + device.getUniqueId(), "Failed to install WDA on device - " + device.getUniqueId());
        }
    } catch (Exception e) {
        throw new TestsigmaException(e.getMessage(), e);
    } finally {
        if ((downloadedWdaFile != null) && downloadedWdaFile.exists()) {
            boolean deleted = downloadedWdaFile.delete();
            if (!deleted) {
                log.error("Error while deleting the downloaded wda.ipa file - " + downloadedWdaFile.getAbsolutePath());
            }
        }
    }
}
Also used : IosDeviceCommandExecutor(com.testsigma.automator.mobile.ios.IosDeviceCommandExecutor) TestsigmaException(com.testsigma.agent.exception.TestsigmaException) File(java.io.File) URL(java.net.URL) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) TestsigmaException(com.testsigma.agent.exception.TestsigmaException)

Example 14 with TestsigmaException

use of com.testsigma.agent.exception.TestsigmaException in project testsigma by testsigmahq.

the class WdaService method checkWDAProcessStatus.

private void checkWDAProcessStatus(MobileDevice device) throws TestsigmaException, AutomatorException {
    IosDeviceCommandExecutor iosDeviceCommandExecutor = new IosDeviceCommandExecutor();
    if ((device.getWdaProcess() != null) && device.getWdaProcess().isAlive()) {
        log.info("Checked if the WDA process is still alive and it seems to be still running on device - " + device.getName());
        return;
    }
    log.info(iosDeviceCommandExecutor.getProcessStreamResponse(device.getWdaProcess()));
    throw new TestsigmaException("Unable to start WDA Process on device - " + device.getName(), "Unable to start WDA Process on device - " + device.getName());
}
Also used : IosDeviceCommandExecutor(com.testsigma.automator.mobile.ios.IosDeviceCommandExecutor) TestsigmaException(com.testsigma.agent.exception.TestsigmaException)

Example 15 with TestsigmaException

use of com.testsigma.agent.exception.TestsigmaException in project testsigma by testsigmahq.

the class DeveloperImageService method fetchDeveloperImageLinks.

public IosDeveloperImageDTO fetchDeveloperImageLinks(String osVersion) throws TestsigmaException {
    IosDeveloperImageDTO iosDeveloperImageDTO;
    log.info("Fetching developer image URL's from testsigma servers...");
    try {
        String authHeader = WebAppHttpClient.BEARER + " " + agentConfig.getJwtApiKey();
        HttpResponse<IosDeveloperImageDTO> response = httpClient.get(ServerURLBuilder.deviceDeveloperImageURL(this.agentConfig.getUUID(), osVersion), new TypeReference<>() {
        }, authHeader);
        log.info("Response of developer image fetch request - " + response.getStatusCode());
        if (response.getStatusCode() == HttpStatus.OK.value()) {
            iosDeveloperImageDTO = response.getResponseEntity();
        } else {
            String errorMsg = String.format("Error while fetching developer image - [%s] - [%s] ", response.getStatusCode(), response.getStatusMessage());
            throw new TestsigmaException(errorMsg, errorMsg);
        }
        log.info("Response from device developer image urls for os version - " + osVersion + " is - " + iosDeveloperImageDTO);
    } catch (Exception e) {
        throw new TestsigmaException(e.getMessage(), e);
    }
    return iosDeveloperImageDTO;
}
Also used : TestsigmaException(com.testsigma.agent.exception.TestsigmaException) IosDeveloperImageDTO(com.testsigma.agent.dto.IosDeveloperImageDTO) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) TestsigmaException(com.testsigma.agent.exception.TestsigmaException)

Aggregations

TestsigmaException (com.testsigma.agent.exception.TestsigmaException)18 AutomatorException (com.testsigma.automator.exceptions.AutomatorException)10 IosDeviceCommandExecutor (com.testsigma.automator.mobile.ios.IosDeviceCommandExecutor)6 File (java.io.File)4 IosDeveloperImageDTO (com.testsigma.agent.dto.IosDeveloperImageDTO)2 AdbCommandExecutionException (com.testsigma.agent.exception.AdbCommandExecutionException)2 NativeBridgeException (com.testsigma.agent.exception.NativeBridgeException)2 URL (java.net.URL)2 Properties (java.util.Properties)2 ToString (lombok.ToString)2 DriverSessionDTO (com.testsigma.agent.dto.DriverSessionDTO)1 DeviceContainerException (com.testsigma.agent.exception.DeviceContainerException)1 DeviceNotConnectedException (com.testsigma.agent.exception.DeviceNotConnectedException)1 MobileLibraryInstallException (com.testsigma.agent.exception.MobileLibraryInstallException)1 TestDeviceSettings (com.testsigma.automator.entity.TestDeviceSettings)1 IOException (java.io.IOException)1 JSONObject (org.json.JSONObject)1