Skip to content

Commit

Permalink
Merge pull request #5469 from jdi-testing/5431
Browse files Browse the repository at this point in the history
#5431 add assertions for Dialog
  • Loading branch information
pnatashap authored Apr 15, 2024
2 parents b31b7d0 + 1184b47 commit 3122b3a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void before() {
@Test(enabled = false, dataProviderClass = DialogDataProvider.class, dataProvider = "simpleDialogDataProvider")
public void simpleDialogTest(String titleText, int index, String text) {
simpleDialogButton.click();
simpleDialogButton.dialog().is().displayed();
simpleDialogButton.dialog().is().displayed().and().has().title();
simpleDialogButton.dialog().title().has().text(titleText);
simpleDialogButton.dialog().list().has().size(3);
simpleDialogButton.dialog().list().items().get(index).has().text(text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import com.epam.jdi.light.asserts.generic.UIAssert;
import com.epam.jdi.light.common.JDIAction;
import com.epam.jdi.light.material.elements.feedback.Dialog;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;

import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert;

/**
* Assertions for {@link Dialog}
*/
// @todo #5341 Assertions to add: have title, have content, have actions
public class DialogAssert extends UIAssert<DialogAssert, Dialog> {

/**
Expand Down Expand Up @@ -58,4 +58,29 @@ public DialogAssert displayed() {
jdiAssert(element().isDisplayed(), Matchers.is(true), "Dialog is not displayed");
return this;
}

public DialogAssert title() {
jdiAssert(element().title().isExist(), Matchers.is(true), "Dialog title is not exist");
return this;
}

public DialogAssert title(Matcher<String> matcher) {
jdiAssert(element().title().text(), matcher);
return this;
}

public DialogAssert content() {
jdiAssert(element().content().isExist(), Matchers.is(true), "Dialog content is not exist");
return this;
}

public DialogAssert actions() {
jdiAssert(element().actionButtons().isExist(), Matchers.is(true), "Dialog actions is not exist");
return this;
}

public DialogAssert noActions() {
jdiAssert(element().actionButtons().isExist(), Matchers.is(false), "Dialog actions is exist");
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
/**
* Assertions for {@link ButtonGroup}.
*/
// #todo 5431 add assertion for button text is exist
public class ButtonGroupAssert extends UISelectAssert<ButtonGroupAssert, ButtonGroup> {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.epam.jdi.light.common.JDIAction;
import com.epam.jdi.light.elements.base.UIBaseElement;
import com.epam.jdi.light.elements.common.UIElement;
import com.epam.jdi.light.material.asserts.feedback.DialogAssert;
import com.epam.jdi.light.material.elements.displaydata.list.SimpleList;
import com.epam.jdi.light.material.elements.inputs.ButtonGroup;
Expand Down Expand Up @@ -42,11 +43,15 @@ public Text title() {
*
* @return list with items within dialog as {@link SimpleList}
*/
// @todo #5431 looks like list is not a required part of Dialog, should be removed
@JDIAction("Get '{name}' list items")
public SimpleList list() {
return new SimpleList().setCore(SimpleList.class, core().find(".MuiList-root"));
}

public UIElement content() {
return core().find(".MuiDialogContent-root");
}
/**
* Gets the text content of this dialog.
*
Expand All @@ -73,6 +78,7 @@ public ButtonGroup actionButtons() {
*
* @return radioButtons of this dialog as {@link RadioButtons}
*/
// @todo #5431 radiobuttons is not a part of standard dialog, should be removed
@JDIAction("Get '{name}' radio buttons")
public RadioButtons radioButtons() {
return new RadioButtons().setCore(RadioButtons.class, core().find(".MuiRadio-root"));
Expand Down

0 comments on commit 3122b3a

Please sign in to comment.