code: def to_capabilities(self):
          
          # This intentionally looks at the internal properties
          # so if a binary or profile has _not_ been set,
          # it will defer to geckodriver to find the system Firefox
          # and generate a fresh profile.
          caps = self._caps
          opts = {}
  
          if self._binary is not None:
              opts["binary"] = self._binary._start_cmd
          if len(self._preferences) > 0:
              opts["prefs"] = self._preferences
          if self._proxy is not None:
              self._proxy.add_to_capabilities(opts)
          if self._profile is not None:
              opts["profile"] = self._profile.encoded
          if len(self._arguments) > 0:
              opts["args"] = self._arguments
  
          opts.update(self.log.to_capabilities())
  
          if len(opts) > 0:
              caps[Options.KEY] = opts
  
          return caps
docs: Marshals the Firefox options to a `moz:firefoxOptions`
          object.