diff --git a/pom.xml b/pom.xml index c01620e53..6a76f8f3d 100644 --- a/pom.xml +++ b/pom.xml @@ -62,7 +62,7 @@ 3.9.0 1.16.0 2.3.32 - 4.13.0 + 4.14.1 4.10.0 1.5.1 1.15.4 diff --git a/serenity-browsermob-plugin/pom.xml b/serenity-browsermob-plugin/pom.xml index 0ff58fd65..ca4529e82 100644 --- a/serenity-browsermob-plugin/pom.xml +++ b/serenity-browsermob-plugin/pom.xml @@ -9,7 +9,7 @@ serenity-browsermob-plugin jar - Serenity Report Resources + Serenity BrowserMob Resources 2.1.5 diff --git a/serenity-core/src/main/java/net/serenitybdd/core/pages/WebElementFacadeImpl.java b/serenity-core/src/main/java/net/serenitybdd/core/pages/WebElementFacadeImpl.java index bd012dd93..dc9a907a5 100644 --- a/serenity-core/src/main/java/net/serenitybdd/core/pages/WebElementFacadeImpl.java +++ b/serenity-core/src/main/java/net/serenitybdd/core/pages/WebElementFacadeImpl.java @@ -372,7 +372,8 @@ public boolean isVisible() { return element.isDisplayed(); } - } catch (ElementNotInteractableException | NoSuchElementException | StaleElementReferenceException | TimeoutException e) { + } catch (ElementNotInteractableException | NoSuchElementException | StaleElementReferenceException | + TimeoutException e) { return false; } } @@ -720,7 +721,8 @@ public boolean isClickable() { waitForCondition().until(elementToBeClickable(getElement())); return true; } - } catch (ElementNotInteractableException | NoSuchElementException | StaleElementReferenceException | TimeoutException e) { + } catch (ElementNotInteractableException | NoSuchElementException | StaleElementReferenceException | + TimeoutException e) { return false; } return false; @@ -740,8 +742,8 @@ public WebElementFacade type(final CharSequence... keysToSend) { return this; } WithRetries.on(this).perform(elementFacade -> { - elementFacade.getElement().clear(); - elementFacade.getElement().sendKeys(nonNullCharSequenceFrom(keyValue)); + elementFacade.getElement().clear(); + elementFacade.getElement().sendKeys(nonNullCharSequenceFrom(keyValue)); }, 12); notifyScreenChange(); return this; @@ -750,6 +752,7 @@ public WebElementFacade type(final CharSequence... keysToSend) { private CharSequence[] nonNullCharSequenceFrom(CharSequence... charSequences) { return Arrays.stream(charSequences).filter(chars -> chars != null).collect(Collectors.toList()).toArray(new CharSequence[]{}); } + /** * Type a value into a field and then press Enter, making sure that the field is empty first. * @@ -1039,7 +1042,7 @@ private void throwShouldBePresentErrorWithCauseIfPresent(final Throwable timeout private boolean hasValueAttribute(WebElement element) { try { return element.getAttribute("value") != null; - } catch (UnsupportedCommandException exception){ + } catch (UnsupportedCommandException exception) { return false; } } @@ -1047,9 +1050,11 @@ private boolean hasValueAttribute(WebElement element) { @Override public Wait waitForCondition() { return new FluentWait<>(driver, webdriverClock, sleeper) - .withTimeout(Duration.ofMillis(waitForTimeoutInMilliseconds)) - .pollingEvery(Duration.ofMillis(WAIT_FOR_ELEMENT_PAUSE_LENGTH)) - .ignoring(NoSuchElementException.class, NoSuchFrameException.class, StaleElementReferenceException.class); + .withTimeout(Duration.ofMillis(waitForTimeoutInMilliseconds)) + .pollingEvery(Duration.ofMillis(WAIT_FOR_ELEMENT_PAUSE_LENGTH)) + .ignoreAll(Arrays.asList(NoSuchElementException.class, + NoSuchFrameException.class, + StaleElementReferenceException.class)); } @Override @@ -1419,6 +1424,7 @@ public SearchContext getShadowRoot() { public ListOfWebElementFacades findNestedElementsMatching(ResolvableElement nestedElement) { return nestedElement.resolveAllFor(this); } + public static ListOfWebElementFacades fromWebElements(List elements) { List facades = elements.stream().map(element -> WebElementFacadeImpl.wrapWebElement(Serenity.getDriver(), element)).collect(Collectors.toList()); return new ListOfWebElementFacades(facades); diff --git a/serenity-core/src/main/java/net/thucydides/core/steps/StepInterceptor.java b/serenity-core/src/main/java/net/thucydides/core/steps/StepInterceptor.java index 87b963e7a..52787c552 100644 --- a/serenity-core/src/main/java/net/thucydides/core/steps/StepInterceptor.java +++ b/serenity-core/src/main/java/net/thucydides/core/steps/StepInterceptor.java @@ -189,7 +189,7 @@ private Method getRoot(Method method) { } private Object testStepResult(final Object obj, final Method method, - final Object[] args, final Method zuperMethod) throws Throwable { + final Object[] args, final Method zuperMethod) throws Throwable { if (!isATestStep(method)) { return runNormalMethod(obj, method, args, zuperMethod); @@ -359,22 +359,22 @@ private boolean returnTypeIsPrimativeFor(Method method) { private Object primativeDefaultValueFor(Method method) { switch (returnTypeOf(method)) { - case VOID: - return null; - case STRING: - return ""; - case LONG: - return 0L; - case INTEGER: - return 0; - case FLOAT: - return 0.0F; - case DOUBLE: - return 0.0D; - case BOOLEAN: - return Boolean.FALSE; - default: - return null; + case VOID: + return null; + case STRING: + return ""; + case LONG: + return 0L; + case INTEGER: + return 0; + case FLOAT: + return 0.0F; + case DOUBLE: + return 0.0D; + case BOOLEAN: + return Boolean.FALSE; + default: + return null; } } @@ -462,7 +462,7 @@ private boolean isIgnored(final Method method) { } private Object runTestStep(final Object obj, final Method method, - final Object[] args, final Method zuperMethod) throws Throwable { + final Object[] args, final Method zuperMethod) throws Throwable { String callingClass = testContext(); LOGGER.debug("STARTING STEP: {} - {}", callingClass, StepName.fromStepAnnotationIn(method).orElse(method.getName())); @@ -527,24 +527,24 @@ private boolean isPending(final Method method) { } private void notifyStepFinishedFor(final Method method, final Object[] args) { - if (TestSession.isSessionStarted()) { - StepFinishedEvent stepFinishedEvent = new StepFinishedEvent(); - LOGGER.debug("SRP:Actor finished step in session " + stepFinishedEvent + " " + Thread.currentThread()); - TestSession.addEvent(stepFinishedEvent); - } - else { + if (TestSession.isSessionStarted()) { + LOGGER.debug("SRP:Actor finished step in session " + Thread.currentThread()); + List screenshotList = TestSession.getTestSessionContext().getStepEventBus().takeScreenshots(); + TestSession.addEvent(new StepFinishedEvent(screenshotList)); + } + else { StepEventBus.getParallelEventBus().stepFinished(); - } + } } private void notifySkippedStepFinishedFor(final Method method, final Object[] args) { if (TestSession.isSessionStarted()) { StepIgnoredEvent stepIgnoredEvent = new StepIgnoredEvent(); TestSession.addEvent(stepIgnoredEvent); - } - else { + } + else { StepEventBus.getParallelEventBus().stepIgnored(); - } + } } private void notifyStepPending(String message) { @@ -559,19 +559,19 @@ private void notifyStepPending(String message) { private void notifyAssumptionViolated(String message) { if (TestSession.isSessionStarted()) { TestSession.addEvent(new AssumptionViolatedEvent(message)); - } - else { + } + else { StepEventBus.getParallelEventBus().assumptionViolated(message); - } + } } private void notifyStepIgnored() { if (TestSession.isSessionStarted()) { TestSession.addEvent(new StepIgnoredEvent()); - } - else { + } + else { StepEventBus.getParallelEventBus().stepIgnored(); - } + } } private String getTestNameFrom(final Method method, final Object[] args) { @@ -579,25 +579,25 @@ private String getTestNameFrom(final Method method, final Object[] args) { } private void notifyStepSkippedFor(final Method method, final Object[] args) { - if (TestSession.isSessionStarted()) { + if (TestSession.isSessionStarted()) { if (isPending(method)) { TestSession.addEvent(new StepPendingEvent()); } else { TestSession.addEvent(new StepIgnoredEvent()); } - } else { + } else { if (isPending(method)) { StepEventBus.getParallelEventBus().stepPending(); } else { StepEventBus.getParallelEventBus().stepIgnored(); } - } + } } private void notifyOfStepFailure(final Object object, final Method method, final Object[] args, - final Throwable cause) throws Throwable { + final Throwable cause) throws Throwable { ExecutedStepDescription description = ExecutedStepDescription.of(testStepClass, getTestNameFrom(method, args), args) - .withDisplayedFields(fieldValuesIn(object)); + .withDisplayedFields(fieldValuesIn(object)); StepFailure failure = new StepFailure(description, cause); @@ -632,7 +632,7 @@ private boolean shouldThrowExceptionImmediately() { private void notifyStepStarted(final Object object, final Method method, final Object[] args) { ExecutedStepDescription description = ExecutedStepDescription.of(testStepClass, getTestNameFrom(method, args), args) - .withDisplayedFields(fieldValuesIn(object)); + .withDisplayedFields(fieldValuesIn(object)); if(TestSession.isSessionStarted()) { StepStartedEvent stepStartedEvent = new StepStartedEvent(description); LOGGER.debug("SRP:Actor started step in session " + stepStartedEvent + " " + Thread.currentThread()); @@ -656,7 +656,7 @@ private Map fieldValuesIn(Object object) { private void notifySkippedStepStarted(final Object object, final Method method, final Object[] args) { ExecutedStepDescription description = ExecutedStepDescription.of(testStepClass, getTestNameFrom(method, args), args) - .withDisplayedFields(fieldValuesIn(object)); + .withDisplayedFields(fieldValuesIn(object)); getStepEventBus().skippedStepStarted(description); } @@ -676,12 +676,12 @@ private String shortenedClassName(String className) { return classNameElements[classNameElements.length - 1]; } private StepEventBus getStepEventBus() { - if (TestSession.isSessionStarted()) { + if (TestSession.isSessionStarted()) { return TestSession.getTestSessionContext().getStepEventBus(); - } - else { + } + else { return StepEventBus.getParallelEventBus(); - } + } } } diff --git a/serenity-model/src/main/java/net/serenitybdd/model/buildinfo/PropertyBasedDriverCapabilityRecord.java b/serenity-model/src/main/java/net/serenitybdd/model/buildinfo/PropertyBasedDriverCapabilityRecord.java index e818caee2..c7f73cca9 100644 --- a/serenity-model/src/main/java/net/serenitybdd/model/buildinfo/PropertyBasedDriverCapabilityRecord.java +++ b/serenity-model/src/main/java/net/serenitybdd/model/buildinfo/PropertyBasedDriverCapabilityRecord.java @@ -33,6 +33,9 @@ public void registerCapabilities(String driver, Properties capabilitiesAsPropert try { File browserProperties = new File(configuration.getOutputDirectory(), "browser-" + driver.toLowerCase() + ".properties"); + if (!browserProperties.getParentFile().exists()) { + browserProperties.getParentFile().mkdirs(); + } try (Writer writer = new OutputStreamWriter(new FileOutputStream(browserProperties), StandardCharsets.UTF_8)) { capabilitiesAsProperties.store(writer, ""); } diff --git a/serenity-model/src/main/java/net/thucydides/model/reports/html/TagFilter.java b/serenity-model/src/main/java/net/thucydides/model/reports/html/TagFilter.java index cbdabe5d3..b9467ef40 100644 --- a/serenity-model/src/main/java/net/thucydides/model/reports/html/TagFilter.java +++ b/serenity-model/src/main/java/net/thucydides/model/reports/html/TagFilter.java @@ -24,7 +24,7 @@ public class TagFilter { private final List excludedTags; private final List ALWAYS_HIDDEN_TAGS - = Arrays.asList("manual-result","manual-test-evidence","manual-last-tested","singlebrowser","Duration"); + = Arrays.asList("manual-result","manual-test-evidence","manual-last-tested","singlebrowser","Duration","context:*"); public TagFilter(){ this(SystemEnvironmentVariables.currentEnvironmentVariables()); diff --git a/serenity-smoketests/src/test/resources/serenity.conf b/serenity-smoketests/src/test/resources/serenity.conf index 1e30ed1cc..482755439 100644 --- a/serenity-smoketests/src/test/resources/serenity.conf +++ b/serenity-smoketests/src/test/resources/serenity.conf @@ -37,7 +37,6 @@ environments { driver = chrome autodownload = true capabilities { - browserName = "chrome" acceptInsecureCerts = true "goog:chromeOptions" { args = ["test-type", "ignore-certificate-errors", "headless", "--window-size=1000,800"