Search in sources :

Example 1 with TestsigmaException

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

the class DriverSessionsService method driverExecutableExists.

public File driverExecutableExists(String browserNameKey, String browserMajorVersion) throws TestsigmaException {
    try {
        String driversFolderPath = PathUtil.getInstance().getDriversPath();
        String driverPath = AutomatorConfig.getInstance().getAppBridge().getDriverExecutablePath(browserNameKey, browserMajorVersion);
        File driverFile = Paths.get(driversFolderPath, driverPath).toFile();
        log.info("Checking if driver executable exists at : " + driverFile.getAbsolutePath());
        return driverFile.exists() ? driverFile : null;
    } catch (AutomatorException e) {
        log.error(e.getMessage(), e);
        throw new TestsigmaException(e.getMessage(), e);
    }
}
Also used : AutomatorException(com.testsigma.automator.exceptions.AutomatorException) TestsigmaException(com.testsigma.agent.exception.TestsigmaException) File(java.io.File)

Example 2 with TestsigmaException

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

the class AndroidDeviceListener method addDeviceListenerCallback.

public void addDeviceListenerCallback() throws TestsigmaException {
    try {
        if (agentConfig.getRegistered().equals(Boolean.FALSE)) {
            log.debug("Skipping agent devices listener callback registration since agent is not registered...");
            return;
        }
        log.debug("Registering agent device listener callbacks...");
        AndroidDebugBridge.addDeviceChangeListener(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 3 with TestsigmaException

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

the class IosDeviceService method getDeviceProperties.

public JSONObject getDeviceProperties(String uniqueId) throws TestsigmaException {
    try {
        log.info("Fetching device properties for device uniqueID - " + uniqueId);
        IosDeviceCommandExecutor iosDeviceCommandExecutor = new IosDeviceCommandExecutor();
        Process p = iosDeviceCommandExecutor.runDeviceCommand(new String[] { "-u", uniqueId, "info", "--json" });
        String devicePropertiesJsonString = iosDeviceCommandExecutor.getProcessStreamResponse(p);
        log.info("Fetched device properties for device - " + uniqueId + ", properties - " + devicePropertiesJsonString);
        JSONObject devicePropertiesJson = new JSONObject(devicePropertiesJsonString);
        log.info("Fetched device properties for device - " + uniqueId + ", json format - " + devicePropertiesJson);
        return devicePropertiesJson;
    } catch (Exception e) {
        throw new TestsigmaException(e.getMessage());
    }
}
Also used : JSONObject(org.json.JSONObject) IosDeviceCommandExecutor(com.testsigma.automator.mobile.ios.IosDeviceCommandExecutor) TestsigmaException(com.testsigma.agent.exception.TestsigmaException) AutomatorException(com.testsigma.automator.exceptions.AutomatorException) TestsigmaException(com.testsigma.agent.exception.TestsigmaException)

Example 4 with TestsigmaException

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

the class DeveloperImageService method downloadDeveloperImage.

public void downloadDeveloperImage(String deviceOsVersion, IosDeveloperImageDTO iosDeveloperImageDTO) throws TestsigmaException {
    try {
        log.info("Downloading developer image files for os version - " + deviceOsVersion);
        File deviceDeveloperImageFilePath = Paths.get(developerImageBaseDirectory(), deviceOsVersion, "DeveloperDiskImage.dmg").toFile();
        log.info("Copying from " + iosDeveloperImageDTO.getDeveloperImageUrl() + " to " + deviceDeveloperImageFilePath);
        FileUtils.copyURLToFile(new URL(iosDeveloperImageDTO.getDeveloperImageUrl()), deviceDeveloperImageFilePath, (60 * 1000), (60 * 1000));
        File deviceDeveloperImageSigFilePath = Paths.get(developerImageBaseDirectory(), deviceOsVersion, "DeveloperDiskImage.dmg.signature").toFile();
        log.info("Copying from " + iosDeveloperImageDTO.getDeveloperImageSignatureUrl() + " to " + deviceDeveloperImageSigFilePath);
        FileUtils.copyURLToFile(new URL(iosDeveloperImageDTO.getDeveloperImageSignatureUrl()), deviceDeveloperImageSigFilePath, (60 * 1000), (60 * 1000));
    } catch (Exception e) {
        throw new TestsigmaException(e.getMessage(), e);
    }
}
Also used : 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 5 with TestsigmaException

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

the class DeveloperImageService method mountDeveloperImage.

public void mountDeveloperImage(MobileDevice device) throws TestsigmaException, AutomatorException {
    log.info("Trying to mount developer image onto the device");
    if (!isDeveloperImageAvailable(device.getOsVersion())) {
        IosDeveloperImageDTO iosDeveloperImageDTO = fetchDeveloperImageLinks(device.getOsVersion());
        downloadDeveloperImage(device.getOsVersion(), iosDeveloperImageDTO);
    }
    String developerImageDirectory = developerImageDirectory(device.getOsVersion()).getAbsolutePath();
    if (new File(developerImageDirectory).exists()) {
        log.info("Developer image exists at - " + developerImageDirectory);
    } else {
        log.info("Developer image could not be fetched for osVersion - " + device.getOsVersion());
    }
    IosDeviceCommandExecutor iosDeviceCommandExecutor = new IosDeviceCommandExecutor();
    Process p = iosDeviceCommandExecutor.runDeviceCommand(new String[] { "-u", device.getUniqueId(), "developer", developerImageDirectory });
    String mountCommandOutput = iosDeviceCommandExecutor.getProcessStreamResponse(p);
    log.info("Response from mount developer image on device - " + mountCommandOutput);
    if (mountCommandOutput.contains("PairingDialogResponsePending")) {
        throw new TestsigmaException("Device is not yet paired. Triggered the trust dialogue. Please accept and try again", "Device is not yet paired. Triggered the trust dialogue. Please accept and try again");
    } else if (mountCommandOutput.contains("DeveloperImage already mounted")) {
        log.info("Developer image is already mounted in the device");
    } else if (mountCommandOutput.contains("DeveloperImage mounted successfully")) {
        log.info("Developer image is mounted successfully on the device");
    } else if (mountCommandOutput.contains("DeviceLocked")) {
        throw new TestsigmaException("Device is locked with a passcode. Please unlock and try again", "Device is locked with a passcode. Please unlock and try again");
    } else {
        throw new TestsigmaException("Unknown error while mounting developer image to the device", "Unknown error while mounting developer image to the device");
    }
}
Also used : IosDeviceCommandExecutor(com.testsigma.automator.mobile.ios.IosDeviceCommandExecutor) TestsigmaException(com.testsigma.agent.exception.TestsigmaException) IosDeveloperImageDTO(com.testsigma.agent.dto.IosDeveloperImageDTO) File(java.io.File)

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