Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed Jul 7, 2023
2 parents 392bf52 + a7c0935 commit e36290b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Collection;
import java.util.List;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.stream.Collectors;

Expand All @@ -21,21 +22,25 @@ public ListOfWebElementFacades(Collection<? extends WebElementFacade> c) {
* Returns a list of the text values of each element in the collection
*/
public List<String> texts() {
return convert((list) -> list.stream().map(WebElementFacade::getText).collect(Collectors.toList()));
return map(WebElementFacade::getText);
}

/**
* Returns a list of the text contents of each element in the collection
* This can be useful when elements are not visible on the page but are still in the DOM.
*/
public List<String> textContents() {
return convert((list) -> list.stream().map(WebElementFacade::getTextContent).collect(Collectors.toList()));
return map(WebElementFacade::getTextContent);
}

public <T> List<T> map(Function<? super WebElementFacade, T> elementConverter) {
return convert((list) -> list.stream().map(elementConverter).collect(Collectors.toList()));
}

public List<? super WebElementFacade> filter(Predicate<? super WebElementFacade> condition) {
return convert((list) -> list.stream().filter(condition).collect(Collectors.toList()));
}

public void setFallback(Function<PageObject, ListOfWebElementFacades> fallbackMethod, PageObject page) {
this.fallback = fallbackMethod;
this.page = page;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ public class SerenityTestExecutionListener implements TestExecutionListener {

private boolean isSerenityTest = false;

public SerenityTestExecutionListener() {
//BaseStepListener baseStepListener = Listeners.getBaseStepListener().withOutputDirectory(getOutputDirectory());
//StepEventBus.eventBusFor(TEST_SOURCE_JUNIT5).registerListener(baseStepListener);
}
public SerenityTestExecutionListener() {}

private static File getOutputDirectory() {
SystemPropertiesConfiguration systemPropertiesConfiguration = new SystemPropertiesConfiguration(new SystemEnvironmentVariables());
Expand All @@ -93,13 +90,6 @@ private void configureParameterizedTestDataFor(TestIdentifier serenityTest) {
dataTables.putAll(parameterTablesForClass);
}
}
//
// private void configureParameterizedTestDataFor(Class<?> javaClass) {
// Map<String, DataTable> parameterTablesForClass = JUnit5DataDrivenAnnotations.forClass(javaClass).getParameterTables();
// if (!parameterTablesForClass.isEmpty()) {
// dataTables.putAll(parameterTablesForClass);
// }
// }

@Override
public synchronized void testPlanExecutionFinished(TestPlan testPlan) {
Expand Down Expand Up @@ -339,7 +329,6 @@ private void recordSummaryData(TestIdentifier testIdentifier, TestExecutionResul
}
testExecutionResult.getThrowable().ifPresent(throwable -> this.summary.addFailure(testIdentifier, throwable));
eventBusFor(testIdentifier).testFailed(testExecutionResult.getThrowable().get());
// StepEventBus.getParallelEventBus().testFailed(testExecutionResult.getThrowable().get());
break;
}
default:
Expand Down Expand Up @@ -450,6 +439,9 @@ private synchronized StepEventBus eventBusFor(TestIdentifier testIdentifier) {
currentEventBus.registerListener(baseStepListener);
currentEventBus.registerListener(new ConsoleLoggingListener(currentEventBus.getEnvironmentVariables()));
logger.trace(" -> ADDED BASE LISTENER " + baseStepListener);
StepListener loggingListener = Listeners.getLoggingListener();
currentEventBus.registerListener(loggingListener);
logger.trace(" -> ADDED LOGGING LISTENER " + loggingListener);
}
logger.trace("SETTING EVENT BUS FOR THREAD " + Thread.currentThread() + " TO " + currentEventBus);
StepEventBus.setCurrentBusToEventBusFor(uniqueTestId);
Expand Down

0 comments on commit e36290b

Please sign in to comment.