code: public static SafariOptions fromCapabilities(Capabilities capabilities)
        throws WebDriverException {
      if (capabilities instanceof SafariOptions) {
        return (SafariOptions) capabilities;
      }
      Object cap = capabilities.getCapability(SafariOptions.CAPABILITY);
      if (cap instanceof SafariOptions) {
        return (SafariOptions) cap;
      } else if (cap instanceof Map) {
        return new SafariOptions(new MutableCapabilities(((Map<String, ?>) cap)));
      } else {
        return new SafariOptions();
      }
    }
docs: Construct a {@link SafariOptions} instance from given capabilities.
  When the {@link #CAPABILITY} capability is set, all other capabilities will be ignored!
  
  @param capabilities Desired capabilities from which the options are derived.
  @return SafariOptions
  @throws WebDriverException If an error occurred during the reconstruction of the options