code: public static boolean runHeadless() {
          String headless = getProgramProperty(HEADLESS);
          if (headless == null) {
              return false;
          }
          if ("".equals(headless)) {
              return true;
          }
          return "true".equalsIgnoreCase(headless);
      }
docs: Determines if the headless parameter was set, to have the browser run in headless mode. This only
  can be used for Chrome and Firefox.
  
  @return boolean: is headless set or not