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;
}
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);
}
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();
}
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);
}
}
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;
}
Aggregations