-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Update test site: Snackbar element
- Loading branch information
Aleksandr_Vorobev
committed
Jun 13, 2024
1 parent
3f4039b
commit dfd98aa
Showing
5 changed files
with
119 additions
and
100 deletions.
There are no files selected for viewing
31 changes: 20 additions & 11 deletions
31
jdi-light-angular-tests/src/main/java/io/github/com/pages/SnackBarPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,39 @@ | ||
package io.github.com.pages; | ||
|
||
import com.epam.jdi.light.angular.elements.complex.Snackbar; | ||
import com.epam.jdi.light.elements.complex.dropdown.Dropdown; | ||
import com.epam.jdi.light.elements.pageobjects.annotations.locators.JDropdown; | ||
import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI; | ||
import com.epam.jdi.light.ui.html.elements.common.Button; | ||
import com.epam.jdi.light.ui.html.elements.common.TextField; | ||
|
||
public class SnackBarPage extends AngularPage { | ||
@UI("#snack-bar-custom-component-input") | ||
public static TextField durationInput; | ||
|
||
@UI("#snack-bar-custom-component-button") | ||
public static Button showCustomSnackbarButton; | ||
|
||
@UI("#snack-bar-custom-component") | ||
public static Snackbar customSnackbar; | ||
|
||
@UI("#snack-bar-message-input") | ||
public TextField messageInput; | ||
public static TextField basicSnackbarMessageInput; | ||
|
||
@UI("#snack-bar-action-input") | ||
public TextField actionInput; | ||
public static TextField basicSnackbarActionInput; | ||
|
||
@UI("#snack-bar-open-button") | ||
public Button openButton; | ||
|
||
public static Button showBasicSnackbarButton; | ||
@UI("//simple-snack-bar") | ||
public Snackbar basicSnackbar; | ||
public static Snackbar snackbar; | ||
|
||
@UI("#snack-bar-custom-component-input") | ||
public TextField durationInput; | ||
@JDropdown(root = "mat-form-field.mat-mdc-form-field-type-mat-select:has(#snack-bar-position-horizontal-select)", value = "span.mat-mdc-select-min-line", list = "//ancestor::body//mat-option") | ||
public static Dropdown horizontalPositionDropdown; | ||
|
||
@UI("#snack-bar-custom-component-button") | ||
public Button customSnackbarOpenButton; | ||
@JDropdown(root = "mat-form-field.mat-mdc-form-field-type-mat-select:has(#snack-bar-position-vertival-select)", value = "span.mat-mdc-select-min-line", list = "//ancestor::body//mat-option") | ||
public static Dropdown verticalPositionDropdown; | ||
|
||
@UI("#snack-bar-custom-component") | ||
public Snackbar customSnackbar; | ||
@UI("#snack-bar-position-open-button") | ||
public static Button showPositionSnackbarButton; | ||
} |
24 changes: 24 additions & 0 deletions
24
jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/PositionAssert.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.epam.jdi.light.angular.asserts; | ||
|
||
import com.epam.jdi.light.angular.elements.enums.Position; | ||
import com.epam.jdi.light.angular.elements.interfaces.HasPosition; | ||
import com.epam.jdi.light.asserts.generic.UIAssert; | ||
import com.epam.jdi.light.common.JDIAction; | ||
import org.hamcrest.Matchers; | ||
|
||
import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert; | ||
|
||
public abstract class PositionAssert<A extends UIAssert<?, ?>, E extends HasPosition> extends UIAssert<A, E> { | ||
|
||
@JDIAction(value = "Assert that '{name}' has position '{0}'", isAssert = true) | ||
public A position(String position) { | ||
jdiAssert(element().position(), Matchers.is(Position.fromFullString(position))); | ||
return (A) this; | ||
} | ||
|
||
@JDIAction(value = "Assert that '{name}' has position '{0}'", isAssert = true) | ||
public A position(Position position) { | ||
jdiAssert(element().position(), Matchers.is(position)); | ||
return (A) this; | ||
} | ||
} |
35 changes: 28 additions & 7 deletions
35
jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/SnackbarAssert.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,52 @@ | ||
package com.epam.jdi.light.angular.asserts; | ||
|
||
import com.epam.jdi.light.angular.elements.complex.Snackbar; | ||
import com.epam.jdi.light.asserts.generic.UIAssert; | ||
import com.epam.jdi.light.common.JDIAction; | ||
import com.jdiai.tools.Timer; | ||
import com.jdiai.tools.func.JAction; | ||
import org.hamcrest.Matchers; | ||
|
||
import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert; | ||
|
||
public class SnackbarAssert extends UIAssert<SnackbarAssert, Snackbar> { | ||
public class SnackbarAssert extends PositionAssert<SnackbarAssert, Snackbar> { | ||
|
||
@JDIAction(value = "Assert that '{name}' has message '{0}'", isAssert = true) | ||
public SnackbarAssert message(String expected) { | ||
jdiAssert(element().messageText(), Matchers.containsString(expected)); | ||
jdiAssert(element().message() | ||
.getText(), Matchers.containsString(expected)); | ||
return this; | ||
} | ||
|
||
@JDIAction(value = "Assert that '{name}' has action icon", isAssert = true) | ||
@JDIAction(value = "Assert that '{name}' has action '{0}'", isAssert = true) | ||
public SnackbarAssert action(String expected) { | ||
jdiAssert(element().action() | ||
.getText(), Matchers.containsString(expected)); | ||
return this; | ||
} | ||
|
||
@JDIAction(value = "Assert that '{name}' has action button", isAssert = true) | ||
public SnackbarAssert hasAction() { | ||
jdiAssert(element().actionIcon() | ||
jdiAssert(element().action() | ||
.isExist(), Matchers.is(true), "Action doesn't exist in snackbar"); | ||
return this; | ||
} | ||
|
||
@JDIAction(value = "Assert that '{name}' has no action icon", isAssert = true) | ||
@JDIAction(value = "Assert that '{name}' has no action button", isAssert = true) | ||
public SnackbarAssert hasNoAction() { | ||
jdiAssert(element().actionIcon() | ||
jdiAssert(element().action() | ||
.isNotExist(), Matchers.is(true), "Action exists in snackbar"); | ||
return this; | ||
} | ||
|
||
@JDIAction(value = "Assert that '{name}' is visible during '{0}' seconds", isAssert = true) | ||
public SnackbarAssert notHidden(int timeoutSec) { | ||
JAction action = () -> { | ||
element().base() | ||
.timer() | ||
.wait(() -> element().isDisplayed()); | ||
}; | ||
boolean result = new Timer(timeoutSec * 1000L).wait(action); | ||
jdiAssert(result ? "displayed" : "hidden", Matchers.is("displayed")); | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters