Skip to content

Commit

Permalink
Refactor frame method to use isEmpty for list check and String check. (
Browse files Browse the repository at this point in the history
…#12894)

Refactor frame method to use isEmpty for list check

- Replace `frameElements.size() == 0` with `frameElements.isEmpty()` in the `frame` method of `RemoteWebDriver`.

This change improves code readability and adheres to best practices for checking if a list is empty.
  • Loading branch information
manuelsblanco authored Oct 8, 2023
1 parent c64e41e commit bceee4e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions java/src/org/openqa/selenium/remote/RemoteWebDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ protected void startSession(Capabilities capabilities) {
String platformString = (String) rawCapabilities.get(PLATFORM_NAME);
Platform platform;
try {
if (platformString == null || "".equals(platformString)) {
if (platformString == null || platformString.isEmpty()) {
platform = Platform.ANY;
} else {
platform = Platform.fromString(platformString);
Expand Down Expand Up @@ -1128,11 +1128,11 @@ public WebDriver frame(String frameName) {
List<WebElement> frameElements =
RemoteWebDriver.this.findElements(
By.cssSelector("frame[name='" + name + "'],iframe[name='" + name + "']"));
if (frameElements.size() == 0) {
if (frameElements.isEmpty()) {
frameElements =
RemoteWebDriver.this.findElements(By.cssSelector("frame#" + name + ",iframe#" + name));
}
if (frameElements.size() == 0) {
if (frameElements.isEmpty()) {
throw new NoSuchFrameException("No frame element found by name or id " + frameName);
}
return frame(frameElements.get(0));
Expand Down

0 comments on commit bceee4e

Please sign in to comment.