use of com.axway.ats.uiengine.exceptions.NotSupportedOperationException in project ats-framework by Axway.
the class SwingTable method setFieldValue.
/**
* Set table field value
*
* @param value the value to set
* @param row the row number
* @param column the column number
* @throws VerificationException if the element doesn't exist
*/
@Override
@PublicAtsApi
public void setFieldValue(String value, int row, int column) {
new SwingElementState(this).waitToBecomeExisting();
JTableFixture tableFixture = (JTableFixture) SwingElementLocator.findFixture(this);
try {
TableCell tableCell = new TableCell(row, column) {
};
// if the cell coordinates are wrong, the exception will be thrown
tableFixture.selectCell(tableCell);
if (tableFixture.component().isCellEditable(row, column)) {
tableFixture.enterValue(tableCell, value);
} else {
throw new NotSupportedOperationException("The table cell [" + row + "," + column + "] is not editable. " + toString());
}
} catch (IndexOutOfBoundsException ioobe) {
throw new UiElementException(ioobe.getMessage(), this);
}
}
use of com.axway.ats.uiengine.exceptions.NotSupportedOperationException 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. Hint: check with resetApp");
}
}
use of com.axway.ats.uiengine.exceptions.NotSupportedOperationException in project ats-framework by Axway.
the class UiEngineUtilities method createScreenshot.
/**
* Create a screenshot image (supported image format/type is PNG).<br>
* If the screenshot image file already exists it will be automatically replaced by the new one.<br>
* <br>
* Currently the supported UI drivers are {@link AbstractRealBrowserDriver} and {@link MobileDriver}:
* <ul>
* <li>{@link AbstractRealBrowserDriver} - the method makes a best effort to create a screenshot,
* depending on the browser to return the following in order of preference:
* <ul>
* <li>Entire page</li>
* <li>Current window</li>
* <li>Visible portion of the current frame</li>
* <li>The screenshot of the entire display containing the browser</li>
* </ul>
* </li>
* <li>{@link MobileDriver} - creates a screenshot of the mobile device screen.<br>
* <b>NOTE:</b> There is a <a href="https://github.com/selendroid/selendroid/issues/325">known issue</a> on Android Virtual Device with <b>"Use Host GPU"</b> enabled option.
* So in order to get a screenshot it should be disabled. Keep in mind that it will affect the performance, because
* it is a performance acceleration option.
* </li>
* </ul>
*
* @param filePath the screenshot image file path
* @param uiDriver {@link UiDriver} instance
*/
@PublicAtsApi
public static void createScreenshot(String filePath, UiDriver uiDriver) {
WebDriver webDriver = null;
if (uiDriver instanceof AbstractRealBrowserDriver) {
AbstractRealBrowserDriver browserDriver = (AbstractRealBrowserDriver) uiDriver;
webDriver = (WebDriver) browserDriver.getInternalObject(InternalObjectsEnum.WebDriver.toString());
} else if (uiDriver instanceof MobileDriver) {
MobileDriver mobileDriver = (MobileDriver) uiDriver;
webDriver = (WebDriver) mobileDriver.getInternalObject(InternalObjectsEnum.WebDriver.toString());
((AppiumDriver) webDriver).context(MobileDriver.NATIVE_CONTEXT);
} else {
throw new NotSupportedOperationException("Currently it is not possible to create a screenshot with driver: " + uiDriver.getClass().getSimpleName());
}
File scrTmpFile = ((TakesScreenshot) webDriver).getScreenshotAs(OutputType.FILE);
File scrFile = new File(filePath);
if (scrFile.exists() && !scrFile.delete()) {
log.warn("The Screenshot image file '" + filePath + "' already exists, but couldn't be deleted. You can find the current Screenshot image here: " + scrTmpFile.getAbsolutePath());
} else if (!scrTmpFile.renameTo(scrFile)) {
// if renameTo() fails we will try to copy the file
try {
new LocalFileSystemOperations().copyFile(scrTmpFile.getCanonicalPath(), scrFile.getCanonicalPath(), true);
scrTmpFile.delete();
} catch (Exception e) {
log.warn("Unable to create Screenshot image file: " + filePath);
}
}
}
Aggregations