Skip to content

Commit

Permalink
Work-in-progress
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed May 13, 2020
1 parent a44b75f commit 7e97e70
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,32 @@ public static <T extends WebElementFacade> T from(WebDriver driver,
}

public static <T extends WebElementFacade> T from(final WebDriver driver,
final By bySelector,
final long timeoutInMilliseconds,
final long waitForTimeoutInMilliseconds,
final String foundBy) {
final By bySelector,
final long timeoutInMilliseconds,
final long waitForTimeoutInMilliseconds,
final String foundBy) {

return (T) new WebElementFacadeImpl(driver, null, driver.findElement(bySelector), timeoutInMilliseconds, waitForTimeoutInMilliseconds, bySelector).foundBy(foundBy);
// WebElement resolvedElement = driver.findElement(bySelector);
//
// WebElementResolver.by(bySelector);
//
// return (resolvedElement instanceof WrapsElement)
// ? (T) new WrappedWebElementFacadeImpl(driver, null, resolvedElement, timeoutInMilliseconds, waitForTimeoutInMilliseconds).foundBy(foundBy)
// : (T) new WebElementFacadeImpl(driver, null, driver.findElement(bySelector), timeoutInMilliseconds, waitForTimeoutInMilliseconds, bySelector).foundBy(foundBy);
}

public static <T extends WebElementFacade> T from(final WebDriver driver,
final WebElement element,
final long timeout) {
final WebElement element,
final long timeout) {
return (element instanceof WrapsElement)
? (T) new WrappedWebElementFacadeImpl(driver, null, element, timeout, timeout).foundBy(element.toString())
: (T) new WebElementFacadeImpl(driver, null, element, timeout, timeout).foundBy(element.toString());
}

public static <T extends WebElementFacade> T from(WebDriver driver, ElementLocator locator, WebElement element, long implicitTimeoutInMilliseconds, long waitForTimeoutInMilliseconds) {
return (element instanceof WrapsElement)
? (T) new WrappedWebElementFacadeImpl(driver, locator, element, implicitTimeoutInMilliseconds, waitForTimeoutInMilliseconds)
: (T) new WebElementFacadeImpl(driver, locator, element, implicitTimeoutInMilliseconds, waitForTimeoutInMilliseconds);
? (T) new WrappedWebElementFacadeImpl(driver, locator, element, implicitTimeoutInMilliseconds, waitForTimeoutInMilliseconds)
: (T) new WebElementFacadeImpl(driver, locator, element, implicitTimeoutInMilliseconds, waitForTimeoutInMilliseconds);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@

public class WebElementResolverByLocator extends WebElementResolver {
private final By bySelector;
private final long implicitTimeoutInMilliseconds;

public WebElementResolverByLocator(By bySelector) {
public WebElementResolverByLocator(By bySelector, long implicitTimeoutInMilliseconds) {
this.bySelector = bySelector;
this.implicitTimeoutInMilliseconds = implicitTimeoutInMilliseconds;
}

public WebElementResolverByLocator(By bySelector) {
this(bySelector, 0L);
}

@Override
public WebElement resolveForDriver(WebDriver driver) {

return driver.findElement(bySelector);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public ScreenshotPhoto takeScreenshot() {

byte[] screenshotData = null;

if (WebDriverFactory.isAlive(driver) && driver instanceof TakesScreenshot) {
if (WebDriverFactory.isAlive(driver) && unproxied(driver) instanceof TakesScreenshot) {
try {
PageSnapshot snapshot = Shutterbug.shootPage(unproxied(driver), scrollStrategy, 500);
screenshotData = asByteArray(snapshot.getImage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,11 @@ public enum ThucydidesSystemProperty {
*/
DELETE_HISTORY_DIRECTORY,

/**
* Generate a CSV report for each test result (true by default)
*/
SERENITY_GENERATE_CSV_REPORTS,

/**
* Add extra columns to the CSV output, obtained from tag values.
*/
Expand Down Expand Up @@ -1601,7 +1606,6 @@ public Boolean booleanFrom(EnvironmentVariables environmentVariables, Boolean de
if (environmentVariables == null) { return defaultValue; }

Optional<String> newPropertyValue = optionalPropertyValueDefinedIn(environmentVariables);
// = Optional.ofNullable(environmentVariables.getProperty(withSerenityPrefix(getPropertyName())));

if (isDefined(newPropertyValue)) {
return Boolean.valueOf(newPropertyValue.get().trim());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public class ConsoleLoggingListener implements StepListener {
" Documentation at https://wakaleo.gitbooks.io/the-serenity-book/content/ \n" +
" Join the Serenity Community on Gitter: https://gitter.im/serenity-bdd/serenity-core \n" +
" Serenity BDD Support and Training at http://serenity-bdd.info/#/trainingandsupport \n" +
" Learn Serenity BDD online at https://www.serenitydojo.net \n" +
"-------------------------------------------------------------------------------------\n";

public static final String SERENITY_SMALL_BANNER =
Expand All @@ -62,7 +61,6 @@ public class ConsoleLoggingListener implements StepListener {
" Documentation at https://wakaleo.gitbooks.io/the-serenity-book/content/ \n" +
" Join the Serenity Community on Gitter: https://gitter.im/serenity-bdd/serenity-core \n" +
" Serenity BDD Support and Training at http://serenity-bdd.info/#/trainingandsupport \n" +
" Learn Serenity BDD online at https://www.serenitydojo.net \n" +
"-------------------------------------------------------------------------------------\n";

// MAIN BANNERS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.io.IOException;
import java.util.Map;

import static net.thucydides.core.ThucydidesSystemProperty.SERENITY_GENERATE_CSV_REPORTS;
import static net.thucydides.core.reports.html.ReportNameProvider.NO_CONTEXT;

public class AggregateReportingTask extends BaseReportingTask implements ReportingTask {
Expand Down Expand Up @@ -40,12 +41,19 @@ public void generateReports() throws IOException {
Map<String, Object> context = freemarker.getBuildContext(testOutcomes, defaultNameProvider, true);

context.put("report", ReportProperties.forAggregateResultsReport());
context.put("csvReport", "results.csv");

generateReportPage(context, HOME_PAGE_TEMPLATE_PATH, "index.html");
generateReportPage(context, BUILD_INFO_TEMPLATE_PATH, "build-info.html");
generateCSVReportFor(testOutcomes, "results.csv");

if (csvReportsAreActivated()) {
context.put("csvReport", "results.csv");
generateCSVReportFor(testOutcomes, "results.csv");
}

LOGGER.debug("Aggregate reports generated in {} ms ", stopwatch.stop());
}

private boolean csvReportsAreActivated() {
return SERENITY_GENERATE_CSV_REPORTS.booleanFrom(environmentVariables, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public void multipleUsersCanUseDifferentBrowsers() {

then(jill).should(seeThat(herProfile, hasProperty("name", equalTo("Jill"))));
and(jill).should(seeThat(herProfile, hasProperty("country", equalTo("France"))));

}


Expand Down Expand Up @@ -98,8 +97,8 @@ public void multipleUsersCanUseDifferentBrowsersInDifferentOrders() {

then(jill).should(seeThat(herProfile, hasProperty("name", equalTo("Jill"))));
and(jill).should(seeThat(herProfile, hasProperty("country", equalTo("France"))));

}

@Steps
OpenTheApplication openedTheApplication;

Expand Down

0 comments on commit 7e97e70

Please sign in to comment.