Example usage for org.openqa.selenium.remote ErrorCodes STALE_ELEMENT_REFERENCE

List of usage examples for org.openqa.selenium.remote ErrorCodes STALE_ELEMENT_REFERENCE

Introduction

In this page you can find the example usage for org.openqa.selenium.remote ErrorCodes STALE_ELEMENT_REFERENCE.

Prototype

int STALE_ELEMENT_REFERENCE

To view the source code for org.openqa.selenium.remote ErrorCodes STALE_ELEMENT_REFERENCE.

Click Source Link

Usage

From source file:sandeep.kb.android.remote.android.AndroidWebDriver.java

License:Apache License

private void throwIfError(final JSONObject jsonObject) {
    int status;//from  ww w  . j  ava 2  s . co  m
    String errorMsg;
    try {
        status = (Integer) jsonObject.get(STATUS);
        errorMsg = String.valueOf(jsonObject.get(VALUE));
    } catch (JSONException e) {
        throw new RuntimeException("Failed to parse JSON Object: " + jsonObject, e);
    }
    switch (status) {
    case ErrorCodes.SUCCESS:
        return;
    case ErrorCodes.NO_SUCH_ELEMENT:
        throw new NoSuchElementException("Could not find " + "WebElement.");
    case ErrorCodes.STALE_ELEMENT_REFERENCE:
        throw new StaleElementReferenceException("WebElement is stale.");
    default:
        if (jsonObject.toString()
                .contains("Result of expression 'd.evaluate' [undefined] is" + " not a function.")) {
            throw new WebDriverException("You are using a version of Android WebDriver APK"
                    + " compatible with ICS SDKs or more recent SDKs. For more info take a look at"
                    + " http://code.google.com/p/selenium/wiki/AndroidDriver#Supported_Platforms. Error:" + " "
                    + jsonObject.toString());
        }
        throw new WebDriverException("Error: " + errorMsg);
    }
}