<commit_before># we create our own Selenium classes here to extend them with user credentials and config

require 'selenium/client'
require 'selenium/webdriver'
require 'selenium/webdriver/remote/http/persistent'

module TestingBot

  class SeleniumWebdriver

    attr_reader :config, :driver
    attr_accessor :session_id_backup

    def initialize(options = {})
      @options = TestingBot::get_config.options
      @options = @options.merge(options)

      http_client = ::Selenium::WebDriver::Remote::Http::Persistent.new
      if ENV['TESTINGBOT_CLIENT_PROXY']
        require 'ostruct'
        http_client.proxy = OpenStruct.new(:http => ENV['TESTINGBOT_CLIENT_PROXY'])
      end
      http_client.timeout = 400
      @driver = ::Selenium::WebDriver.for(:remote, :url => "http://#{@options[:client_key]}:#{@options[:client_secret]}@#{@options[:host]}:#{@options[:port]}/wd/hub", :desired_capabilities => @options[:desired_capabilities], :http_client => http_client)
      http_client.timeout = 120
    end

    def method_missing(meth, *args)
      @driver.send(meth, *args)
    end

    def session_id
      @driver.send(:bridge).session_id
    end

    def stop
      @session_id_backup = session_id
      @driver.quit
    end
  end
end

# if selenium RC, add testingbot credentials to request
if defined?(Selenium) && defined?(Selenium::Client) && defined?(Selenium::Client::Protocol)
  module Selenium
    module Client
      module Protocol
          # add custom parameters for testingbot.com
          def http_request_for_testingbot(verb, args)
            data = http_request_for_original(verb, args)
            data << "&client_key=#{TestingBot.get_config[:client_key]}&client_secret=#{TestingBot.get_config[:client_secret]}" unless TestingBot.get_config[:client_key].nil?
          end

          begin
           alias http_request_for_original http_request_for
           alias http_request_for http_request_for_testingbot
         rescue
         end
      end
    end
  end
end

if defined?(Selenium) && defined?(Selenium::Client) && defined?(Selenium::Client::Base)
  module Selenium
    module Client
      module Base
        DEFAULT_OPTIONS = {
          :screenshot => true<commit_msg>client_key null check for rc test<commit_after># we create our own Selenium classes here to extend them with user credentials and config

require 'selenium/client'
require 'selenium/webdriver'
require 'selenium/webdriver/remote/http/persistent'

module TestingBot

  class SeleniumWebdriver

    attr_reader :config, :driver
    attr_accessor :session_id_backup

    def initialize(options = {})
      @options = TestingBot::get_config.options
      @options = @options.merge(options)

      http_client = ::Selenium::WebDriver::Remote::Http::Persistent.new
      if ENV['TESTINGBOT_CLIENT_PROXY']
        require 'ostruct'
        http_client.proxy = OpenStruct.new(:http => ENV['TESTINGBOT_CLIENT_PROXY'])
      end
      http_client.timeout = 400
      @driver = ::Selenium::WebDriver.for(:remote, :url => "http://#{@options[:client_key]}:#{@options[:client_secret]}@#{@options[:host]}:#{@options[:port]}/wd/hub", :desired_capabilities => @options[:desired_capabilities], :http_client => http_client)
      http_client.timeout = 120
    end

    def method_missing(meth, *args)
      @driver.send(meth, *args)
    end

    def session_id
      @driver.send(:bridge).session_id
    end

    def stop
      @session_id_backup = session_id
      @driver.quit
    end
  end
end

# if selenium RC, add testingbot credentials to request
if defined?(Selenium) && defined?(Selenium::Client) && defined?(Selenium::Client::Protocol)
  module Selenium
    module Client
      module Protocol
          # add custom parameters for testingbot.com
          def http_request_for_testingbot(verb, args)
            raise "Please specify your key and secret in a ~/.testingbot or C:\\.testingbot file" if TestingBot.get_config[:client_key].nil?
            data = http_request_for_original(verb, args)
            data << "&client_key=#{TestingBot.get_config[:client_key]}&client_secret=#{TestingBot.get_config[:client_secret]}"
          end

          begin
           alias http_request_for_original http_request_for
           alias http_request_for http_request_for_testingbot
         rescue
         end
      end
    end
  end
end

if defined?(Selenium) && defined?(Selenium::Client) && defined?(Selenium::Client::Base)
  module Selenium
    module Client
      module Base
        DEFAULT_OPTIONS = {
          :screenshot => true
{'fraction_non_alphanumeric': 0.10599382988100485, 'fraction_numerical': 0.002644336712208021, 'mean_word_length': 3.4587426326129664, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2197545', 'n_tokens_mistral': 1387, 'n_tokens_neox': 1360, 'n_words': 293}