private static void setField(Object o, String fieldName, Object value) throws Exception {
    Class clazz = o.getClass();
    Field field = clazz.getDeclaredField(fieldName);
    field.setAccessible(true);
    field.set(o, value);
  }
Simulates the view as being attached.
core/src/main/java/com/facebook/testing/screenshot/WindowAttachment.java