title: Ruby 'require' errors with Selenium webdriver script
body: <p>I'm trying to execute a script to test some user credentials, and I keep getting errors relating to 'require'. The script takes a csv of usernames and passwords, logs them into a site, and groups them into pass/fail lists.</p>
  
  <p>I confess I didn't write the script- it was provided to us by an outside coder. I've taken a few CS101 classes, and can parse what it's doing and modify it for different domains and credential files, but I'm a total ruby beginner.</p>
  
  <p>=========================</p>
  
  <pre><code>require 'selenium-webdriver'
  require 'rubygems'
  require 'csv'
  
  pass_file = File.open('pass.txt', 'w')
  fail_file = File.open('fail.txt', 'w')
  in_file = File.open('test credentials.csv', 'r')
  
  pass_file.puts "xxxxxx"
  fail_file.puts "xxxxxx"
  
  CSV.foreach(in_file, :col_sep =&gt; ',') do |row|
    driver = Selenium::WebDriver.for :firefox
    driver.get 'https://www.xxxxxx.com/'
  
    driver.find_element(:id =&gt; 'UserNameEntry').send_keys row[0]
    driver.find_element(:id =&gt; 'UserPasswordEntry').send_keys row[1]
    driver.find_element(:id =&gt; 'xxxxxxlNameEntry').clear
    driver.find_element(:id =&gt; 'xxxxxxNameEntry').send_keys "xxxxxx"
    driver.find_element(:xpath =&gt; '//*[@id="cmdLoginButton"]/span').click
    driver.switch_to.window(driver.window_handles[1])
    if driver.title == "Welcome!"
      pass_file.puts row[0]
    elsif driver.title == "Login Unsuccessful"
      fail_file.puts row[0]
    end
    driver.quit
  end
  </code></pre>
  
  <p>==================</p>
  
  <p>When I run it, at first I was getting "`require': no such file to load -- selenium-webdriver (LoadError)
      from xxxxx.rb:1</p>
  
  <p>Then I read on a forum that the requirement for gems should come first. After putting require 'rubygems' before require 'selenium-webdriver', now I get this error:</p>
  
  <p>/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/csv.rb:308:in <code>initialize': can't convert File into String (TypeError)
      from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/csv.rb:308:in</code>open'
      from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/csv.rb:308:in <code>open_reader'
      from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/csv.rb:94:in</code>foreach'</p>
  
  <p>I'm feeling so confused...any help appreciated.</p>