Skip to content
Open
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
17 changes: 9 additions & 8 deletions src/main/java/io/appium/java_client/ErrorCodesMobile.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*
* @author jonahss@gmail.com (Jonah Stiennon)
*/
public class ErrorCodesMobile extends ErrorCodes {

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / JDK 21 build (stable)

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / JDK 21 build (stable)

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / JDK 21 build (stable)

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / JDK 21 build (stable)

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / JDK 21 build (stable)

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / JDK 25 build (stable)

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / JDK 25 build (stable)

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / JDK 25 build (stable)

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / JDK 25 build (stable)

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / JDK 25 build (stable)

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / JDK 17 build (stable)

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / JDK 17 build (stable)

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / JDK 17 build (stable)

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / JDK 17 build (stable)

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / JDK 17 build (stable)

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / e2e - ubuntu-latest android

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / e2e - ubuntu-latest android

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / e2e - ubuntu-latest android

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / e2e - ubuntu-latest android

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / e2e - ubuntu-latest android

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / e2e - ubuntu-latest flutter-android

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / e2e - ubuntu-latest flutter-android

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / e2e - ubuntu-latest flutter-android

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / e2e - ubuntu-latest flutter-android

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / e2e - ubuntu-latest flutter-android

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / e2e - macos-15 ios

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / e2e - macos-15 ios

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / e2e - macos-15 ios

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / e2e - macos-15 ios

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / e2e - macos-15 ios

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / e2e - macos-15 flutter-ios

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / e2e - macos-15 flutter-ios

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / e2e - macos-15 flutter-ios

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / e2e - macos-15 flutter-ios

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

Check warning on line 30 in src/main/java/io/appium/java_client/ErrorCodesMobile.java

View workflow job for this annotation

GitHub Actions / e2e - macos-15 flutter-ios

[removal] ErrorCodes in org.openqa.selenium.remote has been deprecated and marked for removal

public static final int NO_SUCH_CONTEXT = 35;

Expand All @@ -51,21 +51,22 @@
}

/**
* Returns the exception type that corresponds to the given {@code message}or {@code null} if
* there are no matching mobile exceptions.
* Returns the exception type that corresponds to the given {@code message}. Messages that do not
* match a mobile exception are resolved by the standard W3C error mapping.
*
* @param message message An error message returned by Appium server
* @return The exception type that corresponds to the provided error message or {@code null} if
* there are no matching mobile exceptions.
* @return The exception type that corresponds to the provided error message.
*/
@Override
public Class<? extends WebDriverException> getExceptionType(String message) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please mark message arg as nullable

for (Map.Entry<Integer, String> entry : statusToState.entrySet()) {
if (message.contains(entry.getValue())) {
return getExceptionType(entry.getKey());
if (message != null) {
for (Map.Entry<Integer, String> entry : statusToState.entrySet()) {
if (message.contains(entry.getValue())) {
return getExceptionType(entry.getKey());
}
}
}
return null;
return super.getExceptionType(message);
}

/**
Expand Down
30 changes: 30 additions & 0 deletions src/test/java/io/appium/java_client/ErrorCodesMobileTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.appium.java_client;

import org.junit.jupiter.api.Test;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.WebDriverException;

import static org.junit.jupiter.api.Assertions.assertEquals;

class ErrorCodesMobileTest {
private final ErrorCodesMobile errorCodes = new ErrorCodesMobile();

@Test
void resolvesMobileExceptionFromMessage() {
assertEquals(NoSuchContextException.class, errorCodes.getExceptionType("No such context found"));
}

@Test
void resolvesStandardExceptionsFromW3cState() {
assertEquals(NoSuchElementException.class, errorCodes.getExceptionType("no such element"));
assertEquals(StaleElementReferenceException.class,
errorCodes.getExceptionType("stale element reference"));
}

@Test
void resolvesUnknownOrMissingStateToWebDriverException() {
assertEquals(WebDriverException.class, errorCodes.getExceptionType("not a real error"));
assertEquals(WebDriverException.class, errorCodes.getExceptionType((String) null));
}
}
Loading