[wtr-general] Re: How do i read a .txt file using watir script
1In which dir i suppose to save txt file 2getting 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. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com --- 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 watir-general+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [wtr-general] Re: How do i read a .txt file using watir script
[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 pore.pr...@gmail.com wrote: 1In which dir i suppose to save txt file 2getting 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. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com --- 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 watir-general+unsubscr...@googlegroups.com. 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. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com --- 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 watir-general+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[wtr-general] Re: How do i read a .txt file using watir script
hint Google Ruby Class file http://www.ruby-doc.org/core-2.0.0/File.html On Monday, September 14, 2009 5:36:50 AM UTC-5, 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. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com --- 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 watir-general+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[wtr-general] Re: How do i read a .txt file using watir script
Seems like a lot of overhead reading and parsing a file that way. Look at http://roo.rubyforge.org/ the Roo gem. I believe you'll find useage and hints in this list somewhere. You may want to rethink into using Ruby Class Hash for this as well. myParams = { 'url' = 'http://198.44.23.11/DemoApplication.WebUI' , 'username' = 'admin' , 'password' = 'admin!@#' } Then when you need the param puts myParams.fetch('url')#print it browser.text_field(:id,'ID3893').set( myParams.fetch('username') On Monday, September 14, 2009 5:36:50 AM UTC-5, 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. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com --- 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 watir-general+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[wtr-general] Re: How do i read a .txt file using watir script
were you able to find a solution? On Sep 14, 6:36 am, msazeez28july sabdulkha...@gmail.com 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 .txtfilelike belo url =http://198.44.23.11/DemoApplication.WebUI username = admin password = adm...@# path = D:\Watir\WatirScripts Now i need to access the above .txtfileusing watir scripts like openfile,readline 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 afile andreadline by line using watir scripts. Does watir has class or library to supportfileopen inread/write/append modes. Please let me know. Thanks in advance. Regards Syed --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: How do i read a .txt file using watir script
like said begin file = File.new(readfile.txt, r) while (line = file.gets) puts #{counter}: #{line} counter = counter + 1 end file.close rescue = err puts Exception: #{err} err end the above script reads your readfile.txt line by line, the string variable line can be inturn splitted using = sign as the separator and then splitted string could be copied into a hashed array by the Watir is just a browser driver (the best one :), inorder to do all such things you need to know Ruby. From Karim Rayani http://karimnumerouno.wordpress.com On Sat, Sep 19, 2009 at 7:34 PM, crsna g.inamp...@gmail.com wrote: were you able to find a solution? On Sep 14, 6:36 am, msazeez28july sabdulkha...@gmail.com 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 .txtfilelike belo url =http://198.44.23.11/DemoApplication.WebUI username = admin password = adm...@# path = D:\Watir\WatirScripts Now i need to access the above .txtfileusing watir scripts like openfile,readline 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 afile andreadline by line using watir scripts. Does watir has class or library to supportfileopen inread/write/append modes. Please let me know. Thanks in advance. Regards Syed --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: How do i read a .txt file using watir script
begin file = File.new(readfile.rb, r) while (line = file.gets) puts #{counter}: #{line} counter = counter + 1 end file.close rescue = err puts Exception: #{err} err end readfile.rb is your .txt file and line is data from each line in the file. From Karim Rayani On Mon, Sep 14, 2009 at 4:06 PM, msazeez28july sabdulkha...@gmail.com 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 = adm...@# 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 -- Regards, Alkarim Rayani --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: How do i read a .txt file using watir script
Hi, If you interested in your requirement then try this -- http://www.yaml.org/YAML_for_ruby.html On Mon, Sep 14, 2009 at 4:06 PM, msazeez28july sabdulkha...@gmail.comwrote: 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 = adm...@# 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 -- Regards, P.Raveendran http://raveendran.wordpress.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---
[wtr-general] Re: How do i read a .txt file using watir script
Why dont your try .ini file, you keep all the required SN and Password information in .ini file and access it through your script. This will be simple I feel Kiran On Mon, Sep 14, 2009 at 4:06 PM, msazeez28july sabdulkha...@gmail.comwrote: 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 = adm...@# 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 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Watir General group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to watir-general-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/watir-general -~--~~~~--~~--~--~---