We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
As a user I'd like to pass supplier which is a stream reference to the list. Now, it is not working as expected in await conditions.
Example:
@FindBy(css = ".row") private FluentList<RowComponent> componentsList; private Supplier<Boolean> subscribersListContains(String text) { return () -> isSubscribersListContaining(text); } private boolean isSubscribersListContaining(String text) { return componentsList.stream() .anyMatch(subscriber -> subscriber.text().contains(text)); } @Test void streamListChangeTest() { goTo(ELEMENT_REPLACE_URL); await().until(rowsListPage.getComponentsList()).size(4); await().until(subscribersListContains("replaced")); }
Will Pass
but if I change
await().until(rowsListPage.getComponentsList()).size(4);
to
await().until(rowsListPage.getComponentsList()).size(2);
It won't
Please add this piece of code to WaitComponentsListTest test
WaitComponentsListTest
So you have
package org.fluentlenium.test.await.component; import static org.assertj.core.api.Assertions.assertThat; import static org.fluentlenium.assertj.FluentLeniumAssertions.assertThat; import org.fluentlenium.core.FluentControl; import org.fluentlenium.core.FluentPage; import org.fluentlenium.core.annotation.Page; import org.fluentlenium.core.components.ComponentInstantiator; import org.fluentlenium.core.domain.FluentList; import org.fluentlenium.core.domain.FluentWebElement; import org.fluentlenium.test.IntegrationFluentTest; import org.junit.jupiter.api.Test; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import java.util.function.Supplier; class WaitComponentsListTest extends IntegrationFluentTest { private static final int POSITION_OF_REPLACED_ROW = 1; private static final String INITIAL_VALUE_OF_REPLACED_ROW = "row2"; private static final String VALUE_OF_REPLACED_ROW = "replaced row2"; @Page private RowsListPage rowsListPage; @FindBy(css = ".row") private FluentList<RowComponent> componentsList; private Supplier<Boolean> subscribersListContains(String text) { return () -> isSubscribersListContaining(text); } private boolean isSubscribersListContaining(String text) { return componentsList.stream() .anyMatch(subscriber -> subscriber.text().contains(text)); } @Test void streamListChangeTest() { goTo(ELEMENT_REPLACE_URL); await().until(subscribersListContains("replaced")); } @Test void shouldReturnActualValueFromTheChangedList() { goTo(ELEMENT_REPLACE_URL); await().until(rowsListPage.getComponentsList()).size(2); assertThat(rowsListPage.getComponentsList()).hasSize(2); assertThat(rowsListPage.getComponentsList().get(POSITION_OF_REPLACED_ROW).getText()) .isEqualTo(INITIAL_VALUE_OF_REPLACED_ROW); await().until(rowsListPage.getComponentsList()).size(4); assertThat(rowsListPage.getComponentsList()).hasSize(4); assertThat(rowsListPage.getComponentsList().reset().get(POSITION_OF_REPLACED_ROW).getText()) .isEqualTo(VALUE_OF_REPLACED_ROW); } @Test void shouldReturnActualElementWithGetFromTheChangedListWhenUsedPreviously() { goTo(ELEMENT_REPLACE_URL); rowsListPage.getComponentsList().get(1).getText(); await().until(rowsListPage.getComponentsList()).size().greaterThan(3); assertThat(rowsListPage.getComponentsList().get(POSITION_OF_REPLACED_ROW).getText()) .isEqualTo(VALUE_OF_REPLACED_ROW); } @Test void shouldReturnActualElementWithGetFromTheChangedListAfterListReset() { goTo(ELEMENT_REPLACE_URL); rowsListPage.getComponentsList().get(1).getText(); FluentList<RowComponent> rowsList = rowsListPage.getComponentsList().reset(); await().until(rowsList).size().greaterThan(3); assertThat(rowsList.get(POSITION_OF_REPLACED_ROW).getText()) .isEqualTo(VALUE_OF_REPLACED_ROW); } @Test void shouldReturnActualValueFromResetElementWithGetFromTheChangedListAfterListReset() { goTo(ELEMENT_REPLACE_URL); rowsListPage.getComponentsList().get(1).getText(); FluentList<RowComponent> rowsList = rowsListPage.getComponentsList().reset(); await().until(rowsList).size().greaterThan(3); assertThat(rowsList.get(POSITION_OF_REPLACED_ROW).reset().as(RowComponent.class).getText()) .isEqualTo(VALUE_OF_REPLACED_ROW); } @Test void shouldReturnActualElementWithIndexFromTheChangedListAfterListReset() { goTo(ELEMENT_REPLACE_URL); rowsListPage.getComponentsList().get(1).getText(); FluentList<RowComponent> rowsList = rowsListPage.getComponentsList().reset(); await().until(rowsList).size().greaterThan(3); assertThat(rowsList.index(POSITION_OF_REPLACED_ROW).getText()) .isEqualTo(VALUE_OF_REPLACED_ROW); } @Test void shouldReturnActualValueFromResetElementWithIndexFromTheChangedListAfterListReset() { goTo(ELEMENT_REPLACE_URL); RowsListPage rowsPage = newInstance(RowsListPage.class); rowsPage.getComponentsList().get(1).getText(); FluentList<RowComponent> rowsList = rowsPage.getComponentsList().reset(); await().until(rowsList).size().greaterThan(3); assertThat(rowsList.index(1).reset().as(RowComponent.class).getText()) .isEqualTo(VALUE_OF_REPLACED_ROW); } } class RowsListPage extends FluentPage { @FindBy(css = ".row") private FluentList<RowComponent> componentsList; FluentList<RowComponent> getComponentsList() { return componentsList; } } class RowComponent extends FluentWebElement { @FindBy(css = ".inner-row") private FluentWebElement innerTag; RowComponent(WebElement element, FluentControl control, ComponentInstantiator instantiator) { super(element, control, instantiator); } String getText() { return innerTag.text(); } }
Ideally I'd like to skip this wait:
and have only one await await().until(subscribersListContains("replaced")); it is not working
await().until(subscribersListContains("replaced"));
The text was updated successfully, but these errors were encountered:
#787 - Added unit test reproducing a bug
286c18b
#787 - enforced .stream() to refresh FluentList of components
23db6cc
#787 - added test showing another issue with streams()
e12fa8f
#787 - added test showing another issue with await()
bcd4e85
slawekradzyminski
No branches or pull requests
As a user I'd like to pass supplier which is a stream reference to the list. Now, it is not working as expected in await conditions.
Example:
Will Pass
but if I change
await().until(rowsListPage.getComponentsList()).size(4);
to
await().until(rowsListPage.getComponentsList()).size(2);
It won't
Please add this piece of code to
WaitComponentsListTest
testSo you have
Ideally I'd like to skip this wait:
await().until(rowsListPage.getComponentsList()).size(4);
and have only one await
await().until(subscribersListContains("replaced"));
it is not workingThe text was updated successfully, but these errors were encountered: