title: how to write selenium ruby webdriver test results from Ruby terminal to output files
body: <p>Currently, I'm running all selenium scripts in my test suite (written by Selenium Ruby Webdriver) at one time by using rake gem in "Start Command Prompt with Ruby" terminal.</p>
  
  <p>To do this I have to create a file with name "rakefile.rb" with below content and just call "rake" in my terminal: (I have known this knowledge based on the guide of a person in my previous post <a href="https://stackoverflow.com/questions/13881610/how-to-export-results-when-running-selenium-ruby-webdriver-scripts-to-output-fil/13881878#13881878">how to export results when running selenium ruby webdriver scripts to output files from command prompt ruby window</a>).</p>
  
  <pre><code>task :default do
      $stdout = File.new('console.out', 'w')
  
      $stdout.sync = true
  
  
      FileList['test*.rb'].each { |file|
      begin
        ruby file
  
       rescue
  
        puts "The following tests reported unexpected behavior:"
            puts "#{file} \n"
       end
       }
  end
  </code></pre>
  
  <p>However, I do not know how to modify "rakefile.rb" to be able to <strong>export the content of executing each failed tests (that being displayed on my Terminal) to each output file</strong> ? It means that I expect the content of executing each my script will be written to output files instead of displaying on my Ruby terminal (ex: when I'm running the test script "test_GI-1.rb", then the content of executing this script will be written to an output file "test_GI-1.rb.out" instead of showing in my Terminal. </p>
  
  <p>I <strong>modified my "rakefile.rb" to something like ruby file >> test.rb.out, but it does not work at all</strong> (this thing only works when I type directly the thing like ruby test.rb >> output.out on my Ruby Terminal). Anybody please guide me a way. Thanks so much.</p>