Search in sources :

Example 11 with MobileOperationException

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();
}
Also used : MobileOperationException(com.axway.ats.uiengine.exceptions.MobileOperationException) WebElement(org.openqa.selenium.WebElement) VerifyNotEqualityException(com.axway.ats.uiengine.exceptions.VerifyNotEqualityException) MobileOperationException(com.axway.ats.uiengine.exceptions.MobileOperationException) VerifyEqualityException(com.axway.ats.uiengine.exceptions.VerifyEqualityException) MobileElementState(com.axway.ats.uiengine.utilities.mobile.MobileElementState) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 12 with MobileOperationException

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;
}
Also used : MobileOperationException(com.axway.ats.uiengine.exceptions.MobileOperationException) WebElement(org.openqa.selenium.WebElement) VerifyNotEqualityException(com.axway.ats.uiengine.exceptions.VerifyNotEqualityException) MobileOperationException(com.axway.ats.uiengine.exceptions.MobileOperationException) VerifyEqualityException(com.axway.ats.uiengine.exceptions.VerifyEqualityException) MobileElementState(com.axway.ats.uiengine.utilities.mobile.MobileElementState) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 13 with MobileOperationException

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");
    }
}
Also used : MobileOperationException(com.axway.ats.uiengine.exceptions.MobileOperationException) NotSupportedOperationException(com.axway.ats.uiengine.exceptions.NotSupportedOperationException) MobileOperationException(com.axway.ats.uiengine.exceptions.MobileOperationException) NotSupportedOperationException(com.axway.ats.uiengine.exceptions.NotSupportedOperationException) IProcessExecutor(com.axway.ats.core.process.model.IProcessExecutor) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 14 with MobileOperationException

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() + "')");
    }
}
Also used : MobileOperationException(com.axway.ats.uiengine.exceptions.MobileOperationException) MobileOperationException(com.axway.ats.uiengine.exceptions.MobileOperationException) NotSupportedOperationException(com.axway.ats.uiengine.exceptions.NotSupportedOperationException) IProcessExecutor(com.axway.ats.core.process.model.IProcessExecutor) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 15 with MobileOperationException

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  &lt;PACKAGE&gt;<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
}
Also used : MobileOperationException(com.axway.ats.uiengine.exceptions.MobileOperationException) MobileOperationException(com.axway.ats.uiengine.exceptions.MobileOperationException) NotSupportedOperationException(com.axway.ats.uiengine.exceptions.NotSupportedOperationException) IProcessExecutor(com.axway.ats.core.process.model.IProcessExecutor)

Aggregations

MobileOperationException (com.axway.ats.uiengine.exceptions.MobileOperationException)18 PublicAtsApi (com.axway.ats.common.PublicAtsApi)11 NotSupportedOperationException (com.axway.ats.uiengine.exceptions.NotSupportedOperationException)10 IProcessExecutor (com.axway.ats.core.process.model.IProcessExecutor)9 MobileElementState (com.axway.ats.uiengine.utilities.mobile.MobileElementState)7 VerificationException (com.axway.ats.uiengine.exceptions.VerificationException)6 WebElement (org.openqa.selenium.WebElement)6 VerifyEqualityException (com.axway.ats.uiengine.exceptions.VerifyEqualityException)2 VerifyNotEqualityException (com.axway.ats.uiengine.exceptions.VerifyNotEqualityException)2 AndroidDriver (io.appium.java_client.android.AndroidDriver)2 Actions (org.openqa.selenium.interactions.Actions)2 IFileSystemOperations (com.axway.ats.core.filesystem.model.IFileSystemOperations)1 LocalProcessExecutor (com.axway.ats.core.process.LocalProcessExecutor)1 MobileDriver (com.axway.ats.uiengine.MobileDriver)1 MobileEngine (com.axway.ats.uiengine.engine.MobileEngine)1 MobileElement (io.appium.java_client.MobileElement)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1 Dimension (org.openqa.selenium.Dimension)1