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);
}
}
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);
}
}
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());
}
}
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);
}
}
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");
}
}
Aggregations