[wtr-general] Re: Data driven test using .CSV file

2009-07-27 Thread sHiVa

Hi Chris,

Your idea of implemnting a CSV based framework is very nice. It used a
lot in my current framework. - Thanks
Regards
Siva

On Jul 27, 10:56 am, takanobu watanabe  wrote:
> Sorry spread it.
> This is that CSV sample.
> --
> ID,mnemonic,var-name,value
> 1,companycode,company_code,51236
> 2,companyname,company_name,Watir corp
> 3,company-zip-code,zip_code,111011
> 4,company-prefecture,select_prefecture,MA
> 5,company-prefecture for update,select_prefecture2,TT
> 6,company address,address_district,Gossam city
> --
> Just last var is used.
>
>
>
>
>
> On Mon, Jul 27, 2009 at 2:47 PM, takanobu watanabe wrote:
> > miscode
> > mhc = Array::new
> > |
> > V
> > company = Array::new
>
> > On Mon, Jul 27, 2009 at 2:46 PM, takanobu watanabe 
> > wrote:
> >> I use CSV like that below
>
> >> -import.rb-(csv import)-
> >> #! ruby -Ku
> >> #!/usr/bin/env ruby
>
> >> require 'csv'
>
> >> $KCODE = 'UTF8'
>
> >> #import company-data settings
> >>    mhc = Array::new
> >>    CSV.foreach("data/company_var.csv") do |row|
> >>    company << Kconv.kconv(row.join(','),Kconv::UTF8)
> >>    end
>
> >>    $company_code       = company[1].split(',').last.to_s
> >>    $company_name       = company[2].split(',').last.to_s
> >>    $zip_code = company[3].split(',').last.to_s
> >>    $select_prefecture = company[4].split(',').last.to_s
> >>    $select_prefecture2 = company[5].split(',').last.to_s
> >>    $address_district = company[6].split(',').last.to_s
>
> >> something like that.
> >> then you can use that values
> >> -Test case file-
> >> require 'import'
>
> >> some test code...
> >> $company_name...
>
> >> But,Maybe someone knows more simple and smart way.
>
> >> Hope it help you.
> >> It is work,I use it for job too.
> >> tknv/
>
> >> On Mon, Jul 27, 2009 at 1:39 AM, Chris
> >> McMahon wrote:
>
> >>> On Jul 25, 9:03 am, RAM  wrote:
>  Hi allI am very new to Watiranybody here knows how to
>  import value from  .CSV files and Export Results into an .CSV file in
>  Watir.
>  Please reply and provide links if similar subject is already posted.
>
> >>> I wrote a toy framework that does exactly this:
> >>>http://chrismcmahonsblog.blogspot.com/2009/04/ui-test-framework-desig...
>
> >>> Please let us know if that is useful.
>
> >>> -Chris
>
> >> --
> >> tknv/
>
> > --
> > tknv/
>
> --
> tknv/- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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: Data driven test using .CSV file

2009-07-26 Thread takanobu watanabe

miscode
mhc = Array::new
|
V
company = Array::new

On Mon, Jul 27, 2009 at 2:46 PM, takanobu watanabe wrote:
> I use CSV like that below
>
> -import.rb-(csv import)-
> #! ruby -Ku
> #!/usr/bin/env ruby
>
> require 'csv'
>
> $KCODE = 'UTF8'
>
> #import company-data settings
>    mhc = Array::new
>    CSV.foreach("data/company_var.csv") do |row|
>    company << Kconv.kconv(row.join(','),Kconv::UTF8)
>    end
>
>    $company_code       = company[1].split(',').last.to_s
>    $company_name       = company[2].split(',').last.to_s
>    $zip_code = company[3].split(',').last.to_s
>    $select_prefecture = company[4].split(',').last.to_s
>    $select_prefecture2 = company[5].split(',').last.to_s
>    $address_district = company[6].split(',').last.to_s
>
> something like that.
> then you can use that values
> -Test case file-
> require 'import'
>
> some test code...
> $company_name...
>
> But,Maybe someone knows more simple and smart way.
>
> Hope it help you.
> It is work,I use it for job too.
> tknv/
>
> On Mon, Jul 27, 2009 at 1:39 AM, Chris
> McMahon wrote:
>>
>>
>>
>> On Jul 25, 9:03 am, RAM  wrote:
>>> Hi allI am very new to Watiranybody here knows how to
>>> import value from  .CSV files and Export Results into an .CSV file in
>>> Watir.
>>> Please reply and provide links if similar subject is already posted.
>>
>> I wrote a toy framework that does exactly this:
>> http://chrismcmahonsblog.blogspot.com/2009/04/ui-test-framework-design-using-watir.html
>>
>> Please let us know if that is useful.
>>
>> -Chris
>> >>
>>
>
>
>
> --
> tknv/
>



-- 
tknv/

--~--~-~--~~~---~--~~
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: Data driven test using .CSV file

2009-07-26 Thread takanobu watanabe

Sorry spread it.
This is that CSV sample.
--
ID,mnemonic,var-name,value
1,companycode,company_code,51236
2,companyname,company_name,Watir corp
3,company-zip-code,zip_code,111011
4,company-prefecture,select_prefecture,MA
5,company-prefecture for update,select_prefecture2,TT
6,company address,address_district,Gossam city
--
Just last var is used.

On Mon, Jul 27, 2009 at 2:47 PM, takanobu watanabe wrote:
> miscode
> mhc = Array::new
> |
> V
> company = Array::new
>
> On Mon, Jul 27, 2009 at 2:46 PM, takanobu watanabe wrote:
>> I use CSV like that below
>>
>> -import.rb-(csv import)-
>> #! ruby -Ku
>> #!/usr/bin/env ruby
>>
>> require 'csv'
>>
>> $KCODE = 'UTF8'
>>
>> #import company-data settings
>>    mhc = Array::new
>>    CSV.foreach("data/company_var.csv") do |row|
>>    company << Kconv.kconv(row.join(','),Kconv::UTF8)
>>    end
>>
>>    $company_code       = company[1].split(',').last.to_s
>>    $company_name       = company[2].split(',').last.to_s
>>    $zip_code = company[3].split(',').last.to_s
>>    $select_prefecture = company[4].split(',').last.to_s
>>    $select_prefecture2 = company[5].split(',').last.to_s
>>    $address_district = company[6].split(',').last.to_s
>>
>> something like that.
>> then you can use that values
>> -Test case file-
>> require 'import'
>>
>> some test code...
>> $company_name...
>>
>> But,Maybe someone knows more simple and smart way.
>>
>> Hope it help you.
>> It is work,I use it for job too.
>> tknv/
>>
>> On Mon, Jul 27, 2009 at 1:39 AM, Chris
>> McMahon wrote:
>>>
>>>
>>>
>>> On Jul 25, 9:03 am, RAM  wrote:
 Hi allI am very new to Watiranybody here knows how to
 import value from  .CSV files and Export Results into an .CSV file in
 Watir.
 Please reply and provide links if similar subject is already posted.
>>>
>>> I wrote a toy framework that does exactly this:
>>> http://chrismcmahonsblog.blogspot.com/2009/04/ui-test-framework-design-using-watir.html
>>>
>>> Please let us know if that is useful.
>>>
>>> -Chris
>>> >>>
>>>
>>
>>
>>
>> --
>> tknv/
>>
>
>
>
> --
> tknv/
>



-- 
tknv/

--~--~-~--~~~---~--~~
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: Data driven test using .CSV file

2009-07-26 Thread takanobu watanabe

I use CSV like that below

-import.rb-(csv import)-
#! ruby -Ku
#!/usr/bin/env ruby

require 'csv'

$KCODE = 'UTF8'

#import company-data settings
mhc = Array::new
CSV.foreach("data/company_var.csv") do |row|
company << Kconv.kconv(row.join(','),Kconv::UTF8)
end

$company_code   = company[1].split(',').last.to_s
$company_name   = company[2].split(',').last.to_s
$zip_code = company[3].split(',').last.to_s
$select_prefecture = company[4].split(',').last.to_s
$select_prefecture2 = company[5].split(',').last.to_s
$address_district = company[6].split(',').last.to_s

something like that.
then you can use that values
-Test case file-
require 'import'

some test code...
$company_name...

But,Maybe someone knows more simple and smart way.

Hope it help you.
It is work,I use it for job too.
tknv/

On Mon, Jul 27, 2009 at 1:39 AM, Chris
McMahon wrote:
>
>
>
> On Jul 25, 9:03 am, RAM  wrote:
>> Hi allI am very new to Watiranybody here knows how to
>> import value from  .CSV files and Export Results into an .CSV file in
>> Watir.
>> Please reply and provide links if similar subject is already posted.
>
> I wrote a toy framework that does exactly this:
> http://chrismcmahonsblog.blogspot.com/2009/04/ui-test-framework-design-using-watir.html
>
> Please let us know if that is useful.
>
> -Chris
> >
>



-- 
tknv/

--~--~-~--~~~---~--~~
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: Data driven test using .CSV file

2009-07-26 Thread Chris McMahon



On Jul 25, 9:03 am, RAM  wrote:
> Hi allI am very new to Watiranybody here knows how to
> import value from  .CSV files and Export Results into an .CSV file in
> Watir.
> Please reply and provide links if similar subject is already posted.

I wrote a toy framework that does exactly this:
http://chrismcmahonsblog.blogspot.com/2009/04/ui-test-framework-design-using-watir.html

Please let us know if that is useful.

-Chris
--~--~-~--~~~---~--~~
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: Data driven test using .CSV file

2009-07-25 Thread Dylan

It's actually pretty simple if you're just using a CSV file. I don't
have my code in front of me at the moment, but I use a CSV file to
store information for a login test.

Basically, since all CSV is is "comma separated", you just open the
file like normal in ruby, read each line, and use .split to get an
array with each value.

fin = File.open("C:\File\Path\Filename.csv","r")
fin.each_line do |line|
 values = line.split(",")
 #Do stuff with values here
end

for every line in the file, you will end up with an array of each
value on that line.
To write to a CSV file, just do the opposite. Every time you want to
write a line, add commas between your values
(Say that line[] is an array with one line of values you want to add
in a CSV file):

fout = File.open("C:\File\Path\OutputFilename.csv","w")
line.each do |value|
 fout.print "#{value},"
end
print "\n"

You could create a 2 dimensional array with all the data you want to
put into the CSV file and run the loop I just showed you within
another loop for each line:

fout = File.open("C:\File\Path\OutputFilename.csv","w")
allvalues.each do |line|
 line.each do |value|
  fout.print "#{value},"
  end
 print "\n"
end


If you want to add the results to the end of the file rather than
rewriting whatever was there already, change the "w" to "a" in the
File.open line, that will start writing at the end of the file rather
than the beginning.

Hope that helps, don't hesitate to ask more questions if you have
them.

-Dylan

On Jul 25, 8:03 am, RAM  wrote:
> Hi allI am very new to Watiranybody here knows how to
> import value from  .CSV files and Export Results into an .CSV file in
> Watir.
> Please reply and provide links if similar subject is already posted.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---