I suspect that since puts includes a newline character that that's where your problem is.
Try putting a .chomp! at the end of each of your puts statements or use another print variant that doesn't include the newline char.
 
f_e.puts '=> ERROR DETAILS:'.chomp!


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paul Carvalho
Sent: Friday, April 21, 2006 9:00 AM
To: [email protected]
Subject: [Wtr-general] Saving HTML to output adds extra line feeds?

I just wrote a routine that will save the html output to a file if a "Server Error" should appear on a page.  I noticed something odd when I examine the TXT file though - it looks like there are line feed characters at the end of each line.  Depending on the application I use to view the TXT file, I will see either a control character 'square' at the end of each line, or the output looks double spaced.

Does anyone know how I can save the html output without these extra line feed characters?  I am using Watir 1.4.1.

Here is the calling script code:
---
      if ie.contains_text('Server Error')
          create_exception_report( ie.html )
      end
---

Here is a snippet of the method code that writes the output:
---
  def create_exception_report( html_content )
      # A nasty Server Error has occurred.  Open a file to capture the results:
      f_e =  File.new(filename,  "w")
[snip]
      f_e.puts '=> ERROR DETAILS:'
      f_e.puts '-----------------'
      f_e.puts html_content   # <- ** line of interest **
      f_e.puts ''
     
      # Close the file
      f_e.close
  end
---

Here is a sample of the txt file output viewed in a text editor (not NotePad):
---
=> ERROR DETAILS:
-----------------


<BODY bgColor=white><SPAN>

<H1>Server Error in '/ServerName' Application.

<HR width="100%" color=silver SIZE=1>

</H1>

---

What I was expecting:
---
=> ERROR DETAILS:
-----------------
<BODY bgColor=white><SPAN>
<H1>Server Error in '/ServerName' Application.
<HR width="100%" color=silver SIZE=1>
</H1>
---

Any Suggestions?  Is there an alternate command that I can use to write the html output to file?  Perhaps I can scrub the html content to remove these control characters?

Paul.

The content contained in this electronic message is not intended to
constitute formation of a contract binding TWTC. TWTC will be
contractually bound only upon execution, by an authorized officer, of
a contract including agreed terms and conditions or by express
application of its tariffs.

This message is intended only for the use of the individual or entity
to which it is addressed. If the reader of this message is not the
intended recipient, or the employee or agent responsible for
delivering the message to the intended recipient, you are hereby
notified that any dissemination, distribution or copying of this
message is strictly prohibited. If you have received this
communication in error, please notify us immediately by replying to
the sender of this E-Mail or by telephone.
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to