Skip to content
New issue

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

[java] stream api usage enhancement #14707

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion java/src/org/openqa/selenium/By.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public static By cssSelector(String cssSelector) {
public WebElement findElement(SearchContext context) {
List<WebElement> allElements = findElements(context);
if (allElements == null || allElements.isEmpty()) {
throw new NoSuchElementException("Cannot locate an element using " + toString());
throw new NoSuchElementException("Cannot locate an element using " + this);
}
return allElements.get(0);
}
Expand Down
8 changes: 3 additions & 5 deletions java/src/org/openqa/selenium/JavascriptExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.openqa.selenium;

import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;
import org.jspecify.annotations.NullMarked;
Expand Down Expand Up @@ -177,10 +176,9 @@ default void unpin(ScriptKey key) {
* @return The {@link ScriptKey}s of all currently pinned scripts.
*/
default Set<ScriptKey> getPinnedScripts() {
return Collections.unmodifiableSet(
UnpinnedScriptKey.getPinnedScripts(this).stream()
.map(key -> (ScriptKey) key)
.collect(Collectors.toSet()));
return UnpinnedScriptKey.getPinnedScripts(this).stream()
.map(key -> (ScriptKey) key)
.collect(Collectors.toUnmodifiableSet());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public WebElement findElement(SearchContext context) {
return elements.get(0);
}
}
throw new NoSuchElementException("Cannot locate an element using " + toString());
throw new NoSuchElementException("Cannot locate an element using " + this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public ByChained(By... bys) {
public WebElement findElement(SearchContext context) {
List<WebElement> elements = findElements(context);
if (elements.isEmpty())
throw new NoSuchElementException("Cannot locate an element using " + toString());
throw new NoSuchElementException("Cannot locate an element using " + this);
return elements.get(0);
}

Expand Down
Loading