[1] pry(main)> f = File.new('foo.txt', 'w+') #Change the r in the second 
argument because you need to write to the file.
=> #<File:foo.txt>
[2] pry(main)> f.puts 'dsfdsfs' 
=> nil
[3] pry(main)> f.close
=> nil
[4] pry(main)> File.read 'foo.txt'
=> "dsfdsfs\n"
[6] pry(main)> puts "e:\result.txt" #You have to be careful with backslashes in 
text
esult.txt
=> nil
[7] pry(main)> puts "e:\\result.txt" #A second backslash escapes the first.
e:\result.txt


One some approach when you just want to read: File.read "e:\\result.txt"



On Friday, January 10, 2014 3:14 AM, Priti Fhuse <[email protected]> wrote:
 
1>In which dir i suppose to save txt file
2>getting error for 

require 'watir' 

file=File.new("e:\result.txt","r") 

file.puts "Now, write #{i}" 

file.close 


=================error


esult.txt (Errno::EINVAL)Invalid argument - e:
        from 11.rb:3:in `new'
        from 11.rb:3:in `<main>'




On Monday, September 14, 2009 3:36:50 AM UTC-7, msazeez28july wrote:
Hi, 
>      We have watir scripts which requires url, username, password and 
>path (location of the datatables). 
>      These parameters are changing depends upon the server where 
>application is deployed. 
>      I would like to put these information inside a .txt file like 
>belo 
>      url = http://198.44.23.11/ DemoApplication.WebUI 
>      username = admin 
>      password = admin!@# 
>      path = D:\Watir\WatirScripts 
>
>       Now i need to access the above .txt file using watir scripts 
>like open file, read line by line and store each word in a array then 
>       use array elements to get exact values for each parameters and 
>store it on respective variables to use inside scripts. 
>
>      Could you please let me know, whether we can able to open a file 
>and read line by line using watir scripts. Does watir has class 
>or 
>      library to support file open in read/write/append modes. 
>
>      Please let me know. Thanks in advance. 
>
>Regards 
>Syed
-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.
 
[email protected]
http://groups.google.com/group/watir-general
[email protected]
 
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

[email protected]
http://groups.google.com/group/watir-general
[email protected]

--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to