use of com.axway.ats.uiengine.exceptions.MobileOperationException in project ats-framework by Axway.
the class MobileTextBox method pressEnterKey.
@PublicAtsApi
public void pressEnterKey() {
new MobileElementState(this).waitToBecomeExisting();
try {
WebElement textElement = MobileElementFinder.findElement(appiumDriver, this);
textElement.sendKeys("\n");
} catch (Exception se) {
throw new MobileOperationException(this, "pressEnterKey", se);
}
// think time
UiEngineUtilities.sleep();
}
use of com.axway.ats.uiengine.exceptions.MobileOperationException in project ats-framework by Axway.
the class MobileTextBox method setValue.
/**
* Set the Text Box value
*
* @param value
*/
@PublicAtsApi
public MobileTextBox setValue(String value) {
new MobileElementState(this).waitToBecomeExisting();
try {
WebElement textElement = MobileElementFinder.findElement(appiumDriver, this);
textElement.clear();
textElement.sendKeys(value);
} catch (Exception se) {
throw new MobileOperationException(this, "setValue", se);
}
// think time
UiEngineUtilities.sleep();
return this;
}
use of com.axway.ats.uiengine.exceptions.MobileOperationException in project ats-framework by Axway.
the class MobileDriver method clearAppCache.
/**
* Clear application cache
*
* @param applicationPackage application package name
*/
@PublicAtsApi
public void clearAppCache(String applicationPackage) {
if (isAndroidAgent) {
if (this.adbLocation == null) {
throw new MobileOperationException("You must specify a valid Android home location or define " + ANDROID_HOME_ENV_VAR + " environment variable. The ADB executable must be located in a 'platform-tools/' subfolder");
}
String[] commandArguments = new String[] { "shell", "pm", "clear", applicationPackage };
IProcessExecutor pe = null;
int numRetries = 0;
while (numRetries <= MAX_ADB_RELATED_RETRIES) {
if (numRetries > 0) {
log.warn("Retrying to start application action as previous try failed");
}
try {
pe = this.mobileDeviceUtils.executeAdbCommand(commandArguments, false);
} catch (Exception e) {
throw new MobileOperationException("Unable to clear application cache of '" + applicationPackage + "'", e);
}
numRetries++;
if (pe.getExitCode() == 0) {
break;
} else {
if (numRetries <= MAX_ADB_RELATED_RETRIES) {
log.error("Unable to clear application cache of '" + applicationPackage + "'. Start command failed (Exit code: " + pe.getExitCode() + ", STDOUT: '" + pe.getStandardOutput() + "', STDERR: '" + pe.getErrorOutput() + "')");
//try to kill ADB and issue start again
killAdbServer();
} else {
throw new MobileOperationException("Unable to clear application cache of '" + applicationPackage + "'. Clear cache command failed (Exit code: " + pe.getExitCode() + ", STDOUT: '" + pe.getStandardOutput() + "', STDERR: '" + pe.getErrorOutput() + "')");
}
}
}
} else {
//TODO: Find solution. Note that "this.driver.resetApp();" doesn't reset app cache.
throw new NotSupportedOperationException("Currently clear application cache operation for iOS is not implemented");
}
}
use of com.axway.ats.uiengine.exceptions.MobileOperationException in project ats-framework by Axway.
the class MobileDriver method stopIOSSimulator.
/**
* Stopping iOS Simulator
*/
@PublicAtsApi
public void stopIOSSimulator() {
log.info("Stopping simulator on: " + getDeviceDescription());
IProcessExecutor pe = null;
try {
// the simulator window was named "iPhone Simulator" till Xcode 6, now it is "iOS Simulator"
pe = getProcessExecutorImpl("killall", new String[] { "iPhone Simulator", "iOS Simulator" });
pe.execute();
} catch (Exception e) {
throw new MobileOperationException("Unable to stop iOS Simulator", e);
}
if (pe.getExitCode() != 0) {
throw new MobileOperationException("Unable to stop iOS Simulator. Stop command failed (STDOUT: '" + pe.getStandardOutput() + "', STDERR: '" + pe.getErrorOutput() + "')");
}
}
use of com.axway.ats.uiengine.exceptions.MobileOperationException in project ats-framework by Axway.
the class MobileDriver method stopAndroidApplication.
/**
* Stop application using ADB command: ./adb shell am force-stop <PACKAGE><br/>
* for example: ./adb shell am force-stop com.axway.st.mobile
*
* @param applicationPackage application package
*/
private void stopAndroidApplication(String applicationPackage) {
log.info("Stopping application '" + applicationPackage + "' on device: " + getDeviceDescription());
String[] commandArguments = new String[] { "shell", "am", "force-stop", applicationPackage };
IProcessExecutor pe = null;
int numRetries = 0;
while (numRetries <= MAX_ADB_RELATED_RETRIES) {
if (numRetries > 0) {
log.warn("Retrying to start application action as previous try failed");
}
try {
pe = this.mobileDeviceUtils.executeAdbCommand(commandArguments, false);
} catch (Exception e) {
throw new MobileOperationException("Unable to stop Android application with package '" + applicationPackage + "'", e);
}
numRetries++;
if (pe.getExitCode() == 0) {
break;
} else {
if (numRetries <= MAX_ADB_RELATED_RETRIES) {
log.error("Unable to stop Android application with package '" + applicationPackage + "'. Stop command failed (Exit code: " + pe.getExitCode() + ", STDOUT: '" + pe.getStandardOutput() + "', STDERR: '" + pe.getErrorOutput() + "')");
// try to kill ADB and issue stop again
killAdbServer();
} else {
throw new MobileOperationException("Unable to stop Android application with package '" + applicationPackage + "'. Stop command failed (Exit code: " + pe.getExitCode() + ", STDOUT: '" + pe.getStandardOutput() + "', STDERR: '" + pe.getErrorOutput() + "')");
}
}
}
// while
}
Aggregations