code: def file_detector_context(self, file_detector_class, *args, **kwargs):
          
          last_detector = None
          if not isinstance(self.file_detector, file_detector_class):
              last_detector = self.file_detector
              self.file_detector = file_detector_class(*args, **kwargs)
          try:
              yield
          finally:
              if last_detector is not None:
                  self.file_detector = last_detector
docs: Overrides the current file detector (if necessary) in limited context.
          Ensures the original file detector is set afterwards.
  
          Example:
  
          with webdriver.file_detector_context(UselessFileDetector):
              someinput.send_keys('/etc/hosts')
  
          :Args:
           - file_detector_class - Class of the desired file detector. If the class is different
               from the current file_detector, then the class is instantiated with args and kwargs
               and used as a file detector during the duration of the context manager.
           - args - Optional arguments that get passed to the file detector class during
               instantiation.
           - kwargs - Keyword arguments, passed the same way as args.