/com.qsgsoft.MPTabletsExisting/src/main/java/qaframework/Configuration/GetInfo.java

https://bitbucket.org/Pushpa-R/mpoldauto · Java · 23 lines · 17 code · 5 blank · 1 comment · 0 complexity · 59ef838dbd61b2047e9b1e0d3c6ab829 MD5 · raw file

  1. package qaframework.Configuration;
  2. public class GetInfo {
  3. @SuppressWarnings({ "rawtypes", "restriction", "deprecation" })
  4. public static final String getCallingClassName(int parentLevel) {
  5. // Class CN = sun.reflect.Reflection.getCallerClass(parentLevel);
  6. Class CN = sun.reflect.Reflection.getCallerClass(parentLevel);
  7. String className = CN.toString();
  8. int pageIndex = className.indexOf("page");
  9. className = className.substring(pageIndex + 5);
  10. return className;
  11. }
  12. public static final String getCallingFunctionName(int parentLevel) {
  13. StackTraceElement[] stacktrace = Thread.currentThread().getStackTrace();
  14. StackTraceElement e = stacktrace[parentLevel];
  15. String methodName = e.getMethodName();
  16. return methodName;
  17. }
  18. }