/**
  * Get desired capabilities from config
  * @return DesiredCapabilities|null
  * @throws error browser type not supported
  */
 public function _getCapabilities()
 {
     $capabilities = null;
     switch ($this->_browser['type']) {
         default:
             $this->_error('ERROR Sorry this browser type is not supported.');
             break;
         case 'firefox':
             $profile = new FirefoxProfile();
             $capabilities = DesiredCapabilities::firefox();
             if (isset($this->_browser['extensions'])) {
                 foreach ($this->_browser['extensions'] as $i => $ext_path) {
                     if (!is_file($ext_path)) {
                         $this->_error('ERROR The extension file was not found: ' . $ext_path);
                     }
                     $profile->addExtension($ext_path);
                 }
             }
             // Set download preferences for the browser.
             $profile->setPreference("browser.download.folderList", 2);
             $profile->setPreference("xpinstall.signatures.required", false);
             $capabilities->setCapability(FirefoxDriver::PROFILE, $profile);
             break;
         case 'chrome':
             $options = new ChromeOptions();
             $capabilities = DesiredCapabilities::chrome();
             if (isset($this->_browser['extensions'])) {
                 foreach ($this->_browser['extensions'] as $i => $ext_path) {
                     if (!is_file($ext_path)) {
                         $this->_error('ERROR The extension file was not found: ' . $ext_path);
                     }
                     $options->addExtensions($this->_browser['extensions']);
                 }
             }
             // TODO: set options for auto-download if required. (check firefox preferences above).
             $capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
             break;
     }
     return $capabilities;
 }