<commit_before>require 'howitzer/utils/logger'
module CapybaraSettings
  extend self

  def self.base_ff_profile_settings
    profile = Selenium::WebDriver::Firefox::Profile.new
    profile["network.http.phishy-userpass-length"] = 255
    profile["browser.safebrowsing.malware.enabled"] = false
    profile["network.automatic-ntlm-auth.allow-non-fqdn"] = true
    profile["network.ntlm.send-lm-response"] = true
    profile["network.automatic-ntlm-auth.trusted-uris"] = settings.app_main_host
    profile
  end

  Capybara.run_server = false
  Capybara.app_host = ''
  Capybara.default_wait_time = settings.timeout_small
  Capybara.ignore_hidden_elements = true
  case settings.driver.to_sym
    when :selenium
      Capybara.register_driver :selenium do |app|
        params = {browser: settings.sel_browser.to_sym}
        params[:profile] = base_ff_profile_settings if ff_browser?
        Capybara::Selenium::Driver.new app, params
      end
    when :selenium_dev
      Capybara.register_driver :selenium_dev do |app|
        profile = base_ff_profile_settings
        vendor_dir = ENV['HOWITZER_VENDOR_DIR'] || File.join('..', 'vendor')
        raise "Vendor directory was not found('#{vendor_dir}')." unless Dir.exist?(vendor_dir)
        %w(firebug.xpi firepath.xpi).each do |file_name|
          full_path = File.expand_path(file_name, vendor_dir)
          if File.exist?(full_path)
            profile.add_extension
          else
            raise "'#{full_path}' file was not found!"
          end
        end
        profile['extensions.firebug.currentVersion']    = settings.sel_firebug_version # avoid 'first run' tab
        profile["extensions.firebug.previousPlacement"] = 1
        profile["extensions.firebug.onByDefault"]       = true
        profile["extensions.firebug.defaultPanelName"]  = "firepath"
        profile["extensions.firebug.script.enableSites"] = true
        profile["extensions.firebug.net.enableSites"] = true
        profile["extensions.firebug.console.enableSites"] = true

        Capybara::Selenium::Driver.new app, browser: :firefox, profile: profile
      end
    when :webkit
      require 'capybara-webkit'<commit_msg>Corrected default path to VENDOR directory<commit_after>require 'howitzer/utils/logger'
module CapybaraSettings
  extend self

  def self.base_ff_profile_settings
    profile = Selenium::WebDriver::Firefox::Profile.new
    profile["network.http.phishy-userpass-length"] = 255
    profile["browser.safebrowsing.malware.enabled"] = false
    profile["network.automatic-ntlm-auth.allow-non-fqdn"] = true
    profile["network.ntlm.send-lm-response"] = true
    profile["network.automatic-ntlm-auth.trusted-uris"] = settings.app_main_host
    profile
  end

  Capybara.run_server = false
  Capybara.app_host = ''
  Capybara.default_wait_time = settings.timeout_small
  Capybara.ignore_hidden_elements = true
  case settings.driver.to_sym
    when :selenium
      Capybara.register_driver :selenium do |app|
        params = {browser: settings.sel_browser.to_sym}
        params[:profile] = base_ff_profile_settings if ff_browser?
        Capybara::Selenium::Driver.new app, params
      end
    when :selenium_dev
      Capybara.register_driver :selenium_dev do |app|
        profile = base_ff_profile_settings
        vendor_dir = ENV['HOWITZER_VENDOR_DIR'] || File.join(File.dirname(__FILE__), '..', 'vendor')
        raise "Vendor directory was not found('#{vendor_dir}')." unless Dir.exist?(vendor_dir)
        %w(firebug.xpi firepath.xpi).each do |file_name|
          full_path = File.expand_path(file_name, vendor_dir)
          if File.exist?(full_path)
            profile.add_extension
          else
            raise "'#{full_path}' file was not found!"
          end
        end
        profile['extensions.firebug.currentVersion']    = settings.sel_firebug_version # avoid 'first run' tab
        profile["extensions.firebug.previousPlacement"] = 1
        profile["extensions.firebug.onByDefault"]       = true
        profile["extensions.firebug.defaultPanelName"]  = "firepath"
        profile["extensions.firebug.script.enableSites"] = true
        profile["extensions.firebug.net.enableSites"] = true
        profile["extensions.firebug.console.enableSites"] = true

        Capybara::Selenium::Driver.new app, browser: :firefox, profile: profile
      end
    when :webkit
      require 'capybara-webkit'
{'fraction_non_alphanumeric': 0.10763968072976055, 'fraction_numerical': 0.0018244013683010262, 'mean_word_length': 3.3425742574257424, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4027772', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1328, 'n_words': 236}