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