Search in sources :

Example 6 with ActionTitle

use of ru.sbtqa.tag.pagefactory.annotations.ActionTitle in project page-factory-2 by sbtqa.

the class PageFactoryUtils method isRequiredAction.

/**
 * Check whether given method has {@link ActionTitle} or
 * {@link ActionTitles} annotation with required title
 *
 * @param method method to check
 * @param title required title
 * @return true|false
 */
public static Boolean isRequiredAction(Method method, final String title) {
    ActionTitle actionTitle = method.getAnnotation(ActionTitle.class);
    ActionTitles actionTitles = method.getAnnotation(ActionTitles.class);
    List<ActionTitle> actionList = new ArrayList<>();
    if (actionTitles != null) {
        actionList.addAll(Arrays.asList(actionTitles.value()));
    }
    if (actionTitle != null) {
        actionList.add(actionTitle);
    }
    for (ActionTitle action : actionList) {
        String actionValue = action.value();
        try {
            I18N i18n = I18N.getI18n(method.getDeclaringClass(), TagCucumber.getFeature().getI18n().getLocale());
            actionValue = i18n.get(action.value());
        } catch (I18NRuntimeException e) {
            LOG.debug("There is no bundle for translation class. Leave it as is", e);
        }
        if (actionValue.equals(title)) {
            return true;
        }
    }
    return false;
}
Also used : I18NRuntimeException(ru.sbtqa.tag.qautils.i18n.I18NRuntimeException) ActionTitles(ru.sbtqa.tag.pagefactory.annotations.ActionTitles) ArrayList(java.util.ArrayList) ActionTitle(ru.sbtqa.tag.pagefactory.annotations.ActionTitle) I18N(ru.sbtqa.tag.qautils.i18n.I18N)

Example 7 with ActionTitle

use of ru.sbtqa.tag.pagefactory.annotations.ActionTitle in project page-factory-2 by sbtqa.

the class AbstractPage method fillField.

@ActionTitle("fill the field")
public void fillField(String elementTitle, String value) throws PageException {
    Input element = (Input) JDIUtils.getElementByTitle(PageContext.getCurrentPage(), elementTitle);
    element.sendKeys(value);
}
Also used : Input(com.epam.jdi.uitests.web.selenium.elements.common.Input) ActionTitle(ru.sbtqa.tag.pagefactory.annotations.ActionTitle)

Example 8 with ActionTitle

use of ru.sbtqa.tag.pagefactory.annotations.ActionTitle in project page-factory-2 by sbtqa.

the class AbstractPage method clickButton.

@ActionTitle("click the button")
public void clickButton(String elementTitle) throws PageException {
    Button element = (Button) JDIUtils.getElementByTitle(PageContext.getCurrentPage(), elementTitle);
    element.click();
}
Also used : Button(com.epam.jdi.uitests.web.selenium.elements.common.Button) ActionTitle(ru.sbtqa.tag.pagefactory.annotations.ActionTitle)

Example 9 with ActionTitle

use of ru.sbtqa.tag.pagefactory.annotations.ActionTitle in project page-factory-2 by sbtqa.

the class WebElementsPage method assertModalWindowAppears.

/**
 * Wait for a new browser window, then wait for a specific text inside the
 * appeared window List of previously opened windows is being saved before
 * each click, so if modal window appears without click, this method won't
 * catch it. Text is being waited by {@link #assertTextAppears}, so it will
 * be space-trimmed as well
 *
 * @param text text that will be searched inside of the window
 * @throws ru.sbtqa.tag.pagefactory.exceptions.WaitException if
 */
@ActionTitle("ru.sbtqa.tag.pagefactory.modal.window.with.text.appears")
public void assertModalWindowAppears(String text) throws WaitException {
    try {
        String popupHandle = WebExtension.findNewWindowHandle((Set<String>) Stash.getValue("beforeClickHandles"));
        if (null != popupHandle && !popupHandle.isEmpty()) {
            PageFactory.getWebDriver().switchTo().window(popupHandle);
        }
        assertTextAppears(text);
    } catch (Exception ex) {
        throw new WaitException("Modal window with text '" + text + "' didn't appear during timeout", ex);
    }
}
Also used : WaitException(ru.sbtqa.tag.pagefactory.exceptions.WaitException) PageException(ru.sbtqa.tag.pagefactory.exceptions.PageException) WaitException(ru.sbtqa.tag.pagefactory.exceptions.WaitException) ElementNotFoundException(ru.sbtqa.tag.pagefactory.exceptions.ElementNotFoundException) ActionTitle(ru.sbtqa.tag.pagefactory.annotations.ActionTitle)

Example 10 with ActionTitle

use of ru.sbtqa.tag.pagefactory.annotations.ActionTitle in project page-factory-2 by sbtqa.

the class DefaultReflection method isRequiredAction.

@Override
public Boolean isRequiredAction(Method method, String title) {
    ActionTitle actionTitle = method.getAnnotation(ActionTitle.class);
    ActionTitles actionTitles = method.getAnnotation(ActionTitles.class);
    List<ActionTitle> actionList = new ArrayList<>();
    if (actionTitles != null) {
        actionList.addAll(Arrays.asList(actionTitles.value()));
    }
    if (actionTitle != null) {
        actionList.add(actionTitle);
    }
    for (ActionTitle action : actionList) {
        if (action.value().equals(title)) {
            return true;
        }
    }
    return false;
}
Also used : ActionTitles(ru.sbtqa.tag.pagefactory.annotations.ActionTitles) ArrayList(java.util.ArrayList) ActionTitle(ru.sbtqa.tag.pagefactory.annotations.ActionTitle)

Aggregations

ActionTitle (ru.sbtqa.tag.pagefactory.annotations.ActionTitle)13 HtmlFindUtils (ru.sbtqa.tag.pagefactory.find.HtmlFindUtils)4 WebElement (org.openqa.selenium.WebElement)3 ArrayList (java.util.ArrayList)2 ActionTitles (ru.sbtqa.tag.pagefactory.annotations.ActionTitles)2 WebPageChecks (ru.sbtqa.tag.pagefactory.web.checks.WebPageChecks)2 TypifiedElement (ru.yandex.qatools.htmlelements.element.TypifiedElement)2 Button (com.epam.jdi.uitests.web.selenium.elements.common.Button)1 Input (com.epam.jdi.uitests.web.selenium.elements.common.Input)1 Actions (org.openqa.selenium.interactions.Actions)1 ElementNotFoundException (ru.sbtqa.tag.pagefactory.exceptions.ElementNotFoundException)1 PageException (ru.sbtqa.tag.pagefactory.exceptions.PageException)1 WaitException (ru.sbtqa.tag.pagefactory.exceptions.WaitException)1 MenuBlock (ru.sbtqa.tag.pagefactory.pages.htmlelements.blocks.MenuBlock)1 I18N (ru.sbtqa.tag.qautils.i18n.I18N)1 I18NRuntimeException (ru.sbtqa.tag.qautils.i18n.I18NRuntimeException)1 Button (ru.yandex.qatools.htmlelements.element.Button)1 CheckBox (ru.yandex.qatools.htmlelements.element.CheckBox)1 HtmlElement (ru.yandex.qatools.htmlelements.element.HtmlElement)1 Link (ru.yandex.qatools.htmlelements.element.Link)1