@Override
  public String getAttribute(String attribute) {
    if (attribute.equalsIgnoreCase("nativeid")) {
      return getNativeId();
    }
    String name = capitalizeFirstLetter(attribute);
    Method method = getDeclaredMethod("get" + name);
    if (method == null) {
      method = getDeclaredMethod("is" + name);
      if (method == null) {
        throw new NoSuchElementAttributeException("The attribute with name '" + name
            + "' was not found.");
      }
    }
    final Object[] result = new Object[1];
    final Exception[] exception = new Exception[1];
    final Method m = method;
    instrumentation.getInstrumentation().runOnMainSync(new Runnable() {
      @Override
      public void run() {
        try {
          result[0] = m.invoke(getView());
        } catch(Exception e) {
          exception[0] = e;
        }
      }
    });
    if (exception.length == 1 && exception[0] != null) {
      throw new SelendroidException(exception[0]);
    }
    return String.valueOf(result[0]);
  }
Unconventional way of adding a Javascript interface but the main reason why I took this way
is that it is working stable compared to the webview.addJavascriptInterface way.
selendroid-server/src/main/java/io/selendroid/server/model/AndroidNativeElement.java