code: def _setup_firefox(self, capabilities):
          
          if capabilities.get("marionette"):
              gecko_driver = self.config.get('Driver', 'gecko_driver_path')
              self.logger.debug("Gecko driver path given in properties: %s", gecko_driver)
          else:
              gecko_driver = None
  
          # Get Firefox binary
          firefox_binary = self.config.get_optional('Firefox', 'binary')
  
          firefox_options = Options()
  
          if self.config.getboolean_optional('Driver', 'headless'):
              self.logger.debug("Running Firefox in headless mode")
              firefox_options.add_argument('-headless')
  
          self._add_firefox_arguments(firefox_options)
  
          if firefox_binary:
              firefox_options.binary = firefox_binary
  
          log_path = os.path.join(DriverWrappersPool.output_directory, 'geckodriver.log')
          try:
              # Selenium 3
              return webdriver.Firefox(firefox_profile=self._create_firefox_profile(), capabilities=capabilities,
                                       executable_path=gecko_driver, firefox_options=firefox_options, log_path=log_path)
          except TypeError:
              # Selenium 2
              return webdriver.Firefox(firefox_profile=self._create_firefox_profile(), capabilities=capabilities,
                                       executable_path=gecko_driver, firefox_options=firefox_options)
docs: Setup Firefox webdriver
  
          :param capabilities: capabilities object
          :returns: a new local Firefox driver