<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 = settings.custom_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_pattern = File.join(File.expand_path(vendor_dir), file_name)
          if (full_path = Dir[full_path_pattern].first)
            profile.add_extension full_path
          else
            raise "Extension was not found by '#{full_path_pattern}' pattern!"
          end
        end
        profile['extensions.firebug.currentVersion']    = 'Last' # 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'
    when :poltergeist
      require 'capybara/poltergeist'
      Capybara.register_driver :poltergeist do |app|
        Capybara::Poltergeist::Driver.new(
          app, {
                  js_errors: !settings.pjs_ignore_js_errors,
                  phantomjs_options: ["--ignore-ssl-errors=#{settings.pjs_ignore_ssl_errors ? 'yes' : 'no'}" ]
                }
        )
      end
    when :sauce
      caps_opts = {
          platform: settings.sl_platform,
          browser_name: settings.sl_browser_name,
          name: 'Capybara test name should be overwritten',
          "max-duration" => settings.sl_max_duration,
          'idle-timeout' => settings.sl_idle_timeout,
          'selenium-version' => settings.sl_selenium_version,
          'record-screenshots' => settings.sl_record_screenshot,
          'video-upload-on-pass' => settings.sl_video_upload_on_pass
      }

      unless (settings.sl_browser_version.to_s || "").empty?
        caps_opts['browser-version'] = settings.sl_browser_version.to_s<commit_msg>updated naming of sauce sessions<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 = settings.custom_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_pattern = File.join(File.expand_path(vendor_dir), file_name)
          if (full_path = Dir[full_path_pattern].first)
            profile.add_extension full_path
          else
            raise "Extension was not found by '#{full_path_pattern}' pattern!"
          end
        end
        profile['extensions.firebug.currentVersion']    = 'Last' # 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'
    when :poltergeist
      require 'capybara/poltergeist'
      Capybara.register_driver :poltergeist do |app|
        Capybara::Poltergeist::Driver.new(
          app, {
                  js_errors: !settings.pjs_ignore_js_errors,
                  phantomjs_options: ["--ignore-ssl-errors=#{settings.pjs_ignore_ssl_errors ? 'yes' : 'no'}" ]
                }
        )
      end
    when :sauce
      task_name = ENV['RAKE_TASK'].sub(/(?:r?spec|cucumber):?(.*)/, '\1').upcase
      caps_opts = {
          platform: settings.sl_platform,
          browser_name: settings.sl_browser_name,
          name: "#{ENV['RAKE_TASK'] ? (task_name.empty? ? 'ALL' : task_name) : 'CUSTOM'} #{settings.sl_browser_name.upcase}",
          "max-duration" => settings.sl_max_duration,
          'idle-timeout' => settings.sl_idle_timeout,
          'selenium-version' => settings.sl_selenium_version,
          'record-screenshots' => settings.sl_record_screenshot,
          'video-upload-on-pass' => settings.sl_video_upload_on_pass
      }

      unless (settings.sl_browser_version.to_s || "").empty?
        caps_opts['browser-version'] = settings.sl_browser_version.to_s
{'fraction_non_alphanumeric': 0.1132555356074207, 'fraction_numerical': 0.0013464991023339318, 'mean_word_length': 3.0515151515151517, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '4110386', 'n_tokens_mistral': 2097, 'n_tokens_neox': 2047, 'n_words': 338}