Search in sources :

Example 1 with UiElementProperties

use of com.axway.ats.uiengine.elements.UiElementProperties in project ats-framework by Axway.

the class HiddenHtmlButton method clickAndDownloadFile.

/**
 * Click button and download file
 */
@PublicAtsApi
public void clickAndDownloadFile() {
    new HiddenHtmlElementState(this).waitToBecomeExisting();
    new HiddenHtmlElement(uiDriver, new UiElementProperties().addProperty("xpath", properties.getInternalProperty(HtmlElementLocatorBuilder.PROPERTY_ELEMENT_LOCATOR))).clickAndDownloadFile();
    UiEngineUtilities.sleep();
}
Also used : HiddenHtmlElementState(com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState) UiElementProperties(com.axway.ats.uiengine.elements.UiElementProperties) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 2 with UiElementProperties

use of com.axway.ats.uiengine.elements.UiElementProperties in project ats-framework by Axway.

the class UiEngineAspect method logAction.

@Before("(execution(* com.axway.ats.uiengine.elements.html.realbrowser..*.*(..)) " + "|| execution(* com.axway.ats.uiengine.elements.html.hiddenbrowser..*.*(..)) " + "|| execution(* com.axway.ats.uiengine.elements.mobile..*.*(..)) " + "|| execution(* com.axway.ats.uiengine.elements.swing..*.*(..)) " + ") && @annotation(com.axway.ats.common.PublicAtsApi)")
public void logAction(JoinPoint point) throws Throwable {
    // initialize logger
    Logger log = null;
    if (point.getThis() != null) {
        // not a static method
        log = LogManager.getLogger(point.getThis().getClass());
    } else {
        // in case of MobileButton.click() this method will return MobileElement.class, but not MobileButton.class
        // that is why it is better to use point.getThis().getClass(), but if the method is static point.getThis() is null
        log = LogManager.getLogger(point.getSignature().getDeclaringType());
    }
    String methodName = point.getSignature().getName();
    if (log.isTraceEnabled()) {
        log.trace("--> Invoked aspect for method " + methodName);
    }
    String propertiesString = " ";
    if (point.getThis() != null) {
        // not a static method
        UiElementProperties properties = ((UiElement) point.getThis()).getElementProperties();
        if (properties != null) {
            if (properties.containsInternalProperty(UiElementProperties.MAP_ID_INTERNAL_PARAM)) {
                propertiesString = properties.getInternalProperty(UiElementProperties.MAP_ID_INTERNAL_PARAM);
            } else {
                // get the properties in the form '{key1=value1, key2=value2}'
                propertiesString = properties.toString();
                // remove the leading and trailing brackets
                propertiesString = propertiesString.substring(1);
                propertiesString = propertiesString.substring(0, propertiesString.length() - 1);
            }
        }
    }
    StringBuilder message = new StringBuilder();
    Object[] args = point.getArgs();
    if (args.length > 0) {
        message.append(methodName + "( ");
        for (Object o : args) {
            if (o instanceof String) {
                message.append("\"" + o + "\" ,");
            } else if (o != null && o.getClass().isArray()) {
                if (o instanceof Object[]) {
                    message.append(Arrays.asList((Object[]) o) + " ,");
                } else {
                    message.append("[");
                    int length = Array.getLength(o);
                    for (int i = 0; i < length; i++) {
                        message.append(Array.get(o, i) + " ,");
                    }
                    message.delete(message.length() - 2, message.length());
                    message.append("]  ");
                }
            } else {
                message.append(o + " ,");
            }
        }
        message.deleteCharAt(message.length() - 1);
        message.append(") ");
        if (point.getThis() != null) {
            if (propertiesString.trim().isEmpty()) {
                message.insert(0, "[  ].");
            } else {
                message.insert(0, "[ \"" + propertiesString + "\" ].");
            }
        }
    } else if (point.getThis() == null) {
        // a static method
        message.insert(message.length(), "()");
    } else if (propertiesString.trim().isEmpty()) {
        message.insert(0, "[  ]." + methodName);
    } else {
        message.insert(0, "[ \"" + propertiesString + "\" ]." + methodName);
        message.insert(message.length(), "()");
    }
    log.info(message);
}
Also used : UiElement(com.axway.ats.uiengine.elements.UiElement) UiElementProperties(com.axway.ats.uiengine.elements.UiElementProperties) Logger(org.apache.logging.log4j.Logger) Before(org.aspectj.lang.annotation.Before)

Example 3 with UiElementProperties

use of com.axway.ats.uiengine.elements.UiElementProperties in project ats-framework by Axway.

the class SwingEngine method goToContainer.

/**
 * Set active container under the <strong>current</strong> window
 *
 * @param containerMapId container element mapId. The element requires 'name' or 'title' property.
 * @throws ElementNotFoundException if the container element is not found
 */
@PublicAtsApi
public void goToContainer(String containerMapId) {
    UiElementProperties containerProperties = ElementsMap.getInstance().getElementProperties(containerMapId);
    goToContainer(containerProperties);
}
Also used : UiElementProperties(com.axway.ats.uiengine.elements.UiElementProperties) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 4 with UiElementProperties

use of com.axway.ats.uiengine.elements.UiElementProperties in project ats-framework by Axway.

the class HiddenHtmlLink method clickAndDownloadFile.

/**
 * Click link and download file
 */
@PublicAtsApi
public void clickAndDownloadFile() {
    new HiddenHtmlElementState(this).waitToBecomeExisting();
    new HiddenHtmlElement(uiDriver, new UiElementProperties().addProperty("xpath", properties.getInternalProperty(HtmlElementLocatorBuilder.PROPERTY_ELEMENT_LOCATOR))).clickAndDownloadFile();
    UiEngineUtilities.sleep();
}
Also used : HiddenHtmlElementState(com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState) UiElementProperties(com.axway.ats.uiengine.elements.UiElementProperties) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 5 with UiElementProperties

use of com.axway.ats.uiengine.elements.UiElementProperties in project ats-framework by Axway.

the class SwingTabbedPane method selectTabUsingSubElement.

/**
 * Select tab by title using SubElement described in the map file. The required property is 'title'
 *
 * @param mapId the sub-element mapID. This element must have property 'title'
 * @throws VerificationException if the table element doesn't exist
 */
@PublicAtsApi
public void selectTabUsingSubElement(String mapId) {
    new SwingElementState(this).waitToBecomeExisting();
    try {
        String elementMapId = properties.getInternalProperty(UiElementProperties.MAP_ID_INTERNAL_PARAM);
        if (elementMapId == null) {
            throw new UiElementException("The element must be in the MAP file", this);
        }
        UiElementProperties elProperties = ElementsMap.getInstance().getSubElementProperties(elementMapId, mapId);
        String tabTitle = elProperties.getProperty("title");
        if (tabTitle == null) {
            throw new UiElementException("The Sub-Element doesn't have 'title' attribute, " + "which is required for tab selection.", this);
        }
        ((JTabbedPaneFixture) SwingElementLocator.findFixture(this)).selectTab(tabTitle);
    } catch (Exception e) {
        throw new UiElementException(e.getMessage(), this);
    }
}
Also used : SwingElementState(com.axway.ats.uiengine.utilities.swing.SwingElementState) UiElementProperties(com.axway.ats.uiengine.elements.UiElementProperties) UiElementException(com.axway.ats.uiengine.exceptions.UiElementException) JTabbedPaneFixture(org.fest.swing.fixture.JTabbedPaneFixture) UiElementException(com.axway.ats.uiengine.exceptions.UiElementException) VerificationException(com.axway.ats.uiengine.exceptions.VerificationException) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Aggregations

UiElementProperties (com.axway.ats.uiengine.elements.UiElementProperties)5 PublicAtsApi (com.axway.ats.common.PublicAtsApi)4 HiddenHtmlElementState (com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState)2 UiElement (com.axway.ats.uiengine.elements.UiElement)1 UiElementException (com.axway.ats.uiengine.exceptions.UiElementException)1 VerificationException (com.axway.ats.uiengine.exceptions.VerificationException)1 SwingElementState (com.axway.ats.uiengine.utilities.swing.SwingElementState)1 Logger (org.apache.logging.log4j.Logger)1 Before (org.aspectj.lang.annotation.Before)1 JTabbedPaneFixture (org.fest.swing.fixture.JTabbedPaneFixture)1