Skip to content

Commit

Permalink
Updated to Selenium 4.14.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed Oct 14, 2023
1 parent 0bce02a commit 6f8d528
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 57 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<commons.net.version>3.9.0</commons.net.version>
<commons.codec.version>1.16.0</commons.codec.version>
<freemarker.version>2.3.32</freemarker.version>
<selenium.version>4.13.0</selenium.version>
<selenium.version>4.14.1</selenium.version>
<htmlunit.driver.version>4.10.0</htmlunit.driver.version>
<jsonassert.version>1.5.1</jsonassert.version>
<jsoup.version>1.15.4</jsoup.version>
Expand Down
2 changes: 1 addition & 1 deletion serenity-browsermob-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>
<artifactId>serenity-browsermob-plugin</artifactId>
<packaging>jar</packaging>
<name>Serenity Report Resources</name>
<name>Serenity BrowserMob Resources</name>
<properties>
<browsermob.version>2.1.5</browsermob.version>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ public boolean isVisible() {
return element.isDisplayed();
}

} catch (ElementNotInteractableException | NoSuchElementException | StaleElementReferenceException | TimeoutException e) {
} catch (ElementNotInteractableException | NoSuchElementException | StaleElementReferenceException |
TimeoutException e) {
return false;
}
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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.
*
Expand Down Expand Up @@ -1039,17 +1042,19 @@ 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;
}
}

@Override
public Wait<WebDriver> 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
Expand Down Expand Up @@ -1419,6 +1424,7 @@ public SearchContext getShadowRoot() {
public ListOfWebElementFacades findNestedElementsMatching(ResolvableElement nestedElement) {
return nestedElement.resolveAllFor(this);
}

public static ListOfWebElementFacades fromWebElements(List<WebElement> elements) {
List<WebElementFacade> facades = elements.stream().map(element -> WebElementFacadeImpl.wrapWebElement(Serenity.getDriver(), element)).collect(Collectors.toList());
return new ListOfWebElementFacades(facades);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -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<ScreenshotAndHtmlSource> 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) {
Expand All @@ -559,45 +559,45 @@ 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) {
return StepNamer.nameFor(method,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);

Expand Down Expand Up @@ -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());
Expand All @@ -656,7 +656,7 @@ private Map<String, Object> 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);
}

Expand All @@ -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();
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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, "");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class TagFilter {
private final List<String> excludedTags;

private final List<String> 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());
Expand Down
1 change: 0 additions & 1 deletion serenity-smoketests/src/test/resources/serenity.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 6f8d528

Please sign in to comment.