-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#4942 refactoring: Snackbar element #5534
base: angular_rework_development
Are you sure you want to change the base?
Changes from 1 commit
35bfdb3
3f4039b
dfd98aa
bd93eba
bed3032
81d4a9d
30dae94
a361338
f8883aa
bef6a08
c8c580a
551d962
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package com.epam.jdi.light.angular.elements.complex; | ||
|
||
import com.epam.jdi.light.angular.asserts.SnackbarAssert; | ||
import com.epam.jdi.light.angular.elements.enums.Position; | ||
import com.epam.jdi.light.angular.elements.interfaces.HasPosition; | ||
import com.epam.jdi.light.common.JDIAction; | ||
import com.epam.jdi.light.elements.base.UIBaseElement; | ||
import com.epam.jdi.light.elements.common.UIElement; | ||
|
@@ -9,36 +11,59 @@ | |
* To see an example of Snackbar web element please visit https://material.angular.io/components/snack-bar/overview. | ||
*/ | ||
|
||
public class Snackbar extends UIBaseElement<SnackbarAssert> { | ||
protected UIElement message; | ||
protected String messageLocator = "./span"; | ||
|
||
public class Snackbar extends UIBaseElement<SnackbarAssert> implements HasPosition { | ||
@Deprecated | ||
private UIElement message; | ||
@Deprecated | ||
protected UIElement action; | ||
protected String actionLocator = ".//button"; | ||
private String messageLocator = ".mat-mdc-snack-bar-label .mdc-snackbar__label"; | ||
private String actionLocator = ".//button"; | ||
|
||
@Deprecated | ||
public Snackbar() { | ||
message = new UIElement(); | ||
message.core().setLocator(messageLocator); | ||
message.core() | ||
.setLocator(messageLocator); | ||
|
||
action = new UIElement(); | ||
action.core().setLocator(actionLocator); | ||
action.core() | ||
.setLocator(actionLocator); | ||
} | ||
|
||
@Deprecated | ||
@JDIAction("Get '{name}' message") | ||
public String getMessageText() { | ||
return message.getValue(); | ||
} | ||
|
||
@Deprecated | ||
@JDIAction("Get '{name}' action") | ||
public String getActionText() { | ||
return action.getValue(); | ||
} | ||
|
||
@JDIAction("Get '{name}' message") | ||
public String messageText() { | ||
return message.getValue(); | ||
} | ||
|
||
@JDIAction("Get '{name}' action") | ||
public String actionText() { | ||
return action.getValue(); | ||
} | ||
|
||
@Deprecated | ||
@JDIAction("Click '{name}' action") | ||
public void clickAction() { | ||
action.click(); | ||
} | ||
|
||
@JDIAction("Click '{name}' action") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. message не соответсвует действию There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
public UIElement actionIcon() { | ||
return this.action; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. а почему это icon? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. renamed |
||
} | ||
|
||
@Deprecated | ||
@JDIAction("Is '{name}' action displayed") | ||
public boolean isActionDisplayed() { | ||
return action.isDisplayed(); | ||
|
@@ -48,4 +73,19 @@ public boolean isActionDisplayed() { | |
public SnackbarAssert is() { | ||
return new SnackbarAssert().set(this); | ||
} | ||
|
||
@Override | ||
public Position position() { | ||
return null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. странная позиция There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||
} | ||
|
||
@Override | ||
public Position getPositionFromClass(final UIElement element, final String className) { | ||
return HasPosition.super.getPositionFromClass(element, className); | ||
} | ||
|
||
@Override | ||
public Position getPositionFromAttribute(final String attributeValue) { | ||
return HasPosition.super.getPositionFromAttribute(attributeValue); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package com.epam.jdi.light.angular.elements.enums; | ||
|
||
import java.util.Arrays; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import static com.epam.jdi.light.common.Exceptions.runtimeException; | ||
|
||
/** | ||
* Contains named constants representing element positions. | ||
* Each constant includes information about its string representation. | ||
*/ | ||
public enum Position { | ||
TOP("top"), | ||
BOTTOM("bottom"), | ||
LEFT("left"), | ||
RIGHT("right"), | ||
END("end"), | ||
START("start"), | ||
TOP_RIGHT("topRight"), | ||
TOP_LEFT("topLeft"), | ||
TOP_CENTER("topCenter"), | ||
BOTTOM_CENTER("bottomCenter"), | ||
BOTTOM_RIGHT("bottomRight"), | ||
BOTTOM_LEFT("bottomLeft"), | ||
STATIC("Static"); | ||
|
||
private final String value; | ||
|
||
Position(String value) { | ||
this.value = value.toLowerCase(); | ||
} | ||
|
||
/** | ||
* Gets {@link Position} full named constant from the given string. | ||
* | ||
* @param text String value for position | ||
* @return position as {@link Position} | ||
* @throws RuntimeException if no appropriate constant found for given value | ||
*/ | ||
public static Position fromFullString(String text) { | ||
if (StringUtils.isBlank(text)) { | ||
throw runtimeException(String.format("%s: input string can't be empty", Position.class.getName())); | ||
} | ||
return Arrays.stream(Position.values()) | ||
.filter(p -> StringUtils.containsAnyIgnoreCase(text, p.toString())) | ||
.max(Comparator.comparing(p -> p.toString().length())) | ||
.orElseThrow(() -> runtimeException(String.format("No appropriate %s constant found for value '%s'", Position.class.getName(), text))); | ||
} | ||
|
||
public static Position fromClasses(List<String> classes, String stylePrefix, String stylePostfix) { | ||
if (classes == null || classes.isEmpty() || StringUtils.isBlank(stylePrefix)) { | ||
throw runtimeException(String.format("%s: input string can't be empty", | ||
Position.class.getName())); | ||
} | ||
String positionClass = classes.stream() | ||
.filter(c -> StringUtils.containsAnyIgnoreCase(c, stylePrefix)) | ||
.map(c -> c.replaceFirst(stylePrefix, "").replace(stylePostfix, "")) | ||
.findFirst().orElse(""); | ||
if (StringUtils.isBlank(positionClass)) { | ||
throw runtimeException(String.format("%s: input string can't be empty", | ||
Position.class.getName())); | ||
} | ||
return Arrays.stream(Position.values()) | ||
.filter(p -> StringUtils.equalsIgnoreCase(positionClass, p.toString())) | ||
.findAny() | ||
.orElseThrow(() -> runtimeException(String.format("No appropriate %s constant found for value '%s'", | ||
Position.class.getName(), positionClass))); | ||
} | ||
|
||
/** | ||
* Gets string representation of element position in CamelCase (e.g. "bottom", "bottomLeft"). | ||
* | ||
* @return element position as {@link String} | ||
*/ | ||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
пакет не релизился, ничего не надо depricated, просто удаляем
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed