[wtr-general] Re: Access an object

2009-01-14 Thread TCBlues

Thanks a lot.

On 14 ene, 03:59, Richard Lawrence rslawre...@gmail.com wrote:
 You don't get back the specific object type from element_by_xpath, so
 some methods don't work. But this works:

 b = Watir::IE.new
 b.goto 'http://www.google.com/'
 txt = b.element_by_xpath(//*...@name='q'])
 txt.value = 'Richard Lawrence'
 btn = b.element_by_xpath(//*...@name='btnG'])
 btn.click

 So you might try the value property instead of the set method.

 Richard

 On Tue, Jan 13, 2009 at 9:46 AM, TCBlues tcbl...@gmail.com wrote:

  Thanks for your answer.

  In the case the object is a textField or a listField I'm trying to set
  the control with:
  ie.element_by_xpath(//*...@name=imp1]).set(testing)

  but an error comes up: 13:in `method_missing': unknown property or
  method `set' (WIN32OLERuntimeError)
--~--~-~--~~~---~--~~
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: Access an object

2009-01-14 Thread wesley chen
Thanks very much. I study from you again, :)
Thanks.
Wesley Chen.


On Wed, Jan 14, 2009 at 11:59 AM, Richard Lawrence rslawre...@gmail.comwrote:


 You don't get back the specific object type from element_by_xpath, so
 some methods don't work. But this works:

 b = Watir::IE.new
 b.goto 'http://www.google.com/'
 txt = b.element_by_xpath(//*...@name='q'])
 txt.value = 'Richard Lawrence'
 btn = b.element_by_xpath(//*...@name='btnG'])
 btn.click

 So you might try the value property instead of the set method.

 Richard

 On Tue, Jan 13, 2009 at 9:46 AM, TCBlues tcbl...@gmail.com wrote:
 
  Thanks for your answer.
 
  In the case the object is a textField or a listField I'm trying to set
  the control with:
  ie.element_by_xpath(//*...@name=imp1]).set(testing)
 
  but an error comes up: 13:in `method_missing': unknown property or
  method `set' (WIN32OLERuntimeError)
 

 


--~--~-~--~~~---~--~~
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 to store data from a CSV file into an array

2009-01-14 Thread Walter Kruse

Hi Margam

You should really read the Ruby documentation on accessing array elements. 
Nevertheless, here is how I would do it:

require 'csv'

array = []

CSV::Reader.parse(File.open('gmail.csv')) do |row|
  array  row.join(',')
end

puts array[10].split(',')[1] # row 11 (column 2)

puts array[(1 + rand(22))].split(',')[(1 + rand(1))] # truly random, but I 
don't think that's what you meant

regards
Walter

Date: Tue, 13 Jan 2009 14:35:48 -0800
From: nk.mar...@gmail.com
To: watir-general@googlegroups.com
Subject: [wtr-general] Re: How to store data from a CSV file into an array

Hello,
Thanks for the snippet. IT works.
But I guess I should have posed my question differently. The new snippet and 
the first snippet works great to get every value (from second column) from 
every row  of the CSV file and inserting into an Array. 


PLease see the attached CSV file.
My problem is: How do I start grabbing data from a random row:  say row 11 
(column 2) and store in an array, instead of starting from the beginning of the 
CSV file?
Or in other words, Is there a way to specify a particular row to start 
collecting data using the CSV module?


I hope my question is clear.
Thank you.

Margam

On Tue, Jan 13, 2009 at 12:32 PM, Bill Agee billa...@gmail.com wrote:



Hey,



One way to do this is to use a counter while iterating over the rows:



require 'csv'

array = []

row_count = 0

CSV::Reader.parse(File.open('foo.csv')) do |row|

  row_count += 1

  # Don't save the value on the first row

  next if (row_count == 1)

  array  row[1]

end



That code will increment row_count by 1 at the beginning of each

iteration performed.  So as shown, you can use the counter to exit the

block early if you are on row 1.



For more info, I'd suggest checking out the Ruby programming resources

on the Wiki, at:



http://wiki.openqa.org/display/WTR/Learning+Ruby



The Ruby Cheat Sheet document there contains a brief introduction to

iteration, and the other docs go into more depth.







On Tue, Jan 13, 2009 at 11:48 AM, Margam nk.mar...@gmail.com wrote:



 Hello everyone,

 Can anyone help with my previous question.

 So I  am trying to get data starting from a particular row (instead

 of from the first row) of a CSV file and have not been very

 successful.

 Say I want to start getting data from Row 2 and as before Column 2 of

 my CSV file.

 I tried the following, but did not work:



 array=[]

 CSV::Reader.parse(File.open('gmail.csv')) { |row| array  [1][1] }

 CSV::Reader.parse(File.open('gmail.csv')) { |row| array  ['r1c1'] }



 Can anyone help me? How should I be specifying the row and columns to

 be

 saved in the array?

 Thank you very much.

 Margam



 On Jan 11, 5:28 pm, Margam nk.mar...@gmail.com wrote:

 Hello Bill,

 So I  was trying to get data starting from a particular row (instead

 of from the first row) and have not been very successful.

 Say I want to start getting data from Row 2 and as before Column 2.

 I tried the following, but did not 
 work:CSV::Reader.parse(File.open('gmail.csv')) { |row| array  [1][1] 
 }CSV::Reader.parse(File.open('gmail.csv')) { |row| array  ['r1c1'] }




 Can you help me? How should I be specifying the row and columns to be

 saved in the array?

 Thank you very much.



 Margam



 On Jan 8, 3:16 pm, Bill Agee billa...@gmail.com wrote:



  Thecsvmodule should be able to do what you need, without much fuss:



  require 'csv'

  array = []CSV::Reader.parse(File.open('foo.csv')) { |row| array  row[1] }



  That snippet will open 'foo.csv', and for each row, push the second

  column's value onto the array.  Note that if you need to deal with

  lines that are commented, empty, or otherwise invalid, a little more

  work would be needed to handle those situations.



  More info:



 http://www.ruby-doc.org/stdlib/libdoc/csv/rdoc/index.html(Clickon

  theCSV::Reader class for applicable docs)



  On Thu, Jan 8, 2009 at 2:48 PM, Margam nk.mar...@gmail.com wrote:



   Hello all,

   I am trying to get data from a particular column (second in my case)

   of anCSVfile and store it into an array. And then use the array

   elements within my script

   Curerntly my script(below) uses the datahandler.rb

   ---

   require 'watir'

   require 'watir/datahandler'

   require test/unit



   #Get Data from theCSVfile and store in variables.CSVfile is in the

   same folder as the script

   d = DataHandler.new(gmail.csv)



   $dataarray=[] #Creating an empty array



   #storing each value from theCSVfile to the array elements. Note:

   Value is the header of the second column in theCSVfile.

   $dataarray[0]=d.data[0].Value

   $dataarray[1]=d.data[1].Value

   $dataarray[2]=d.data[2].Value

   $dataarray[3]=d.data[3].Value

   ...



   #rest of script, where the array element are used.

   ---

   The above approach works. But I don't want to manually enter each

   value from the file into each array element.

   Is there an easier 

[wtr-general] watir 1.6.2 and extended ascii character representation in Firefox

2009-01-14 Thread bwaybandit

Here is a piece of code that represents the characters (╖Äïσ) properly
in IE.

require 'win32ole'
WIN32OLE.codepage = WIN32OLE::CP_UTF8

browser.text_field(:id, 'blah').value='my characters'

In Firefox, the characters in the text field are represented as: 记录阿里巴
巴

The above does not seem like a hex representation of those characters.
Any ideas on how to get this working correctly in Firefox and out of
curiosity, does anyone know what that represents?

Thanks,

Len

--~--~-~--~~~---~--~~
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: Best Way for Checking Name Fields?

2009-01-14 Thread rob

name_field_with_space = @browser.html.scan(/\sname\s*=\s*[\']\w+\s+
[\']/i)
assert(name_field_with_space.empty?, message=name tag field with
trailing space found)


This was the code I used to solve my problem.  I used regex to get the
name='whatever '.  The scan method will search within the html for any
name='whatever '. (In the regex I specify that it should find a
trailing space or more (\s+ ).  If no space after, then ignore it.
Using assert, I will throw an error if it finds at least one name
field with a trailing space.  The assert can be upgraded to return the
name fields it finds by adding #{name_field_with_space} to the message
output.  Hope this helps anyone that might need something similar.


On Jan 13, 12:53 pm, rob rs...@verizon.net wrote:
 Thanks for your suggestion.  I work in a Mac environment and the
 script worked.

 However, I solved my problem using the .scan method, regex, and an
 assert.  If anyone is curious how I did it, just ask.

 On Jan 12, 4:59 pm, gem dandy d-l-br...@roadrunner.com wrote:

  Here ya go rob,

  ***
  =begin
  ##
  This is a short test to reveal the text in a entry box what is
  expected (or not expected).
  ##
  =end

  require 'watir/ie'
  require 'watir/WindowHelper'
  require 'test/unit'
  require 'win32ole'

  # open a browser
  $ie = Watir::IE.new

  $ie.goto(http://groups.google.com/group/watir-general/browse_thread/
  thread/2751583d3eb37e50)

  $ie.form(:name, 'gs2').text_field(:name, 'q').set('\'whatever \'')

  # Flash the table cell System Name text
  $ie.form(:name, 'gs2').text_field(:name, 'q').flash

  # Reveal the text
  myValue = $ie.form(:name, 'gs2').text_field(:name, 'q').value

  puts My value is   + myValue
  sleep 1

  # If whatever has a trailing space, the test will fail.
  # If whatever has no trailing space, the test will pass.

  # Remove the trailing space from set('\'whatever \'') below
  #   to make the test pass

    if (myValue == '\'whatever\'')
       puts Test passed
    else
      puts Test failed
    end
  sleep 5

  $ie.close

  ***

  gem dandy

  On Jan 12, 7:21 pm, gem dandy d-l-br...@roadrunner.com wrote:

   Hold the presses -

   I just ran another test on this and it doesn't pass when
   checking for the correct text. I'll post another update soon.

   gem dandy

   On Jan 12, 7:05 pm, gem dandy d-l-br...@roadrunner.com wrote:

Rob,

Give the below script a  try. It puts 'whatever ' (with trailing
space)
into a text box in this thread and then checks to see if it contains
'whatever' (no trailing space).

***

=begin
##
This is a short test to reveal the text in a entry
box what is expected (or not expected).
##
=end

require 'watir/ie'
require 'watir/WindowHelper'
require 'test/unit'
require 'win32ole'

# open a browser
$ie = Watir::IE.new

$ie.goto(http://groups.google.com/group/watir-general/browse_thread/
thread/2751583d3eb37e50)
$ie.form(:name, 'gs2').text_field(:name, 'q').set('\'whatever \'')

# Flash the table cell System Name text
$ie.form(:name, 'gs2').text_field(:name, 'q').flash

# Reveal the System Name text
myValue = $ie.form(:name, 'gs2').text_field(:name, 'q').value

puts My value is   + myValue
sleep 1

  if (myValue == whatever)
     puts Test passed
  else
    puts Test failed
  end
sleep 5

$ie.close

***
Let me know if you have any problems. good luck,
Gem Dandy

On Jan 11, 9:26 pm, rob rs...@verizon.net wrote:

 I have several forms that have

 name='whatever '

 within the tag.  Notice the trailing [space] after the word whatever.
 What would be the best way to check every tag on the page that has
 name='whatever ' to ensure there is no trailing space.  If there is a
 space, I will throw an error message.

 Any help is appreciated.  Thanks.
--~--~-~--~~~---~--~~
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] running unit tests for watir-1.6.2

2009-01-14 Thread Monkeybuns

I'm trying to run the Unit Tests defined in the watir tutorial (http://
wiki.openqa.org/display/WTR/Run+the+Watir+Unit+Tests).

I gather that this does not work anymore in 1.6.2 because the
directory structure has changed from 1.5.6.

Have others run into this?  Are there any suggested workarounds?

--~--~-~--~~~---~--~~
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: running unit tests for watir-1.6.2

2009-01-14 Thread Charley Baker
http://wiki.openqa.org/display/WTR/Running+Unit+Tests+in+Development

-c

On Wed, Jan 14, 2009 at 10:00 AM, Monkeybuns shaml...@twia.org wrote:


 I'm trying to run the Unit Tests defined in the watir tutorial (http://
 wiki.openqa.org/display/WTR/Run+the+Watir+Unit+Tests).

 I gather that this does not work anymore in 1.6.2 because the
 directory structure has changed from 1.5.6.

 Have others run into this?  Are there any suggested workarounds?

 


--~--~-~--~~~---~--~~
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: IE hoging memory

2009-01-14 Thread Bret Pettichord

Turn off page caching?

Bissquitt wrote:
 I did find one answer a few pages back but they involved closing IE

 On Jan 13, 2:47 pm, Bissquitt bissqu...@gmail.com wrote:
   
 So im running a script that goes to MANY webpages and I noticed that
 each web page it goes to it still stores the information so that I can
 go back causing the IE process to take up slightly more memory each
 page it goes to. Is there a solution to this that doesn't require me
 to close the browser and reopen it each time?
 
 
   


--~--~-~--~~~---~--~~
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 to create a Hash Table using CSV or FaterCSV

2009-01-14 Thread Karthikeyan Margam
Hi Alex,
Thank you very much for the explanation.

Margam

On Tue, Jan 13, 2009 at 11:39 PM, Alex Collins a.j.collins...@gmail.comwrote:


 My apologies - knocked send whilst getting onto the train.

 In this case, you are using the CSV modules to load strings as key/
 value pairs into a hash. The important bit being that both the key,
 and the value when retrieved from the hash will be strings.

 Let us examines few snippets of your code:

 hash[URL]

 This tries to access the value in the hash stored for the key
 contained in the URL constant. In Ruby, If is starts with a capital,
 it is a constant. As you haven't initialised this constant, Ruby does
 not know which element to look at. Hence the error.

 So the quotation marks are required because your key is a string.

 And alternative would be to use a symbol eg:

 hash[row[0].to_sym] = row[1]

 You could then access it with:

 hash[:URL]

 (warning: I'm not certain about capitals as symbols - may need to be
 lower case)

 Likewise, when you access the value, you are accessing a String object
 (an instance of a Ruby class). That it is a string is indicated by the
 double quotes.

 You may be interested in looking at YAML. It is a markup form
 available in Ruby which is typically used for what you are doing.

 Hope this helps,

 Alex

 On 14 Jan 2009, at 01:19, Margam nk.mar...@gmail.com wrote:

 
  Follow Up
  Hello All,
  After googling for some time, I found an easy way to get the data into
  an Hash. Thanks to One Mr.Ryan.
  -
  hash = {}
  CSV.foreach('test.csv') do |row|
   hash[row[0]] = row[1]
  end
  -
 
  But I have some questions regarding accessing the values using the Key
  field.
  Based on the CSV file example I had mentioned in my previous entry:
  1. When I do:
  $browser.goto(hash[URL])
  I get a error:
  --
 NameError: uninitialized constant TestSuite::URL
 c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/
  active_support/dependencies.rb:493:in `const_missing'
 csvdriven.rb:102:in `test00_gmail'
  --
  But works fine when I do: $browser.goto(hash['URL']).
  Why are the single quotes required?
 
  2. When I try to output the values using the KEys like this:
  puts hash['URL']
  the output looks like this:  http://gamil.com;
  Why does the output has the double quotes?
 
  Hope my questions are clear. Thank you.
 
  Margam
 
  On Jan 13, 3:58 pm, Margam nk.mar...@gmail.com wrote:
  Hello All,
  I have been recently learning to use both the CSV module and the
  FasterCSV gem to create an array from a CSV file.
  Say my CSV file(file.csv) looks like this (first row is the header,
  not used in script):
  Parameter,Value
  URL,http://gamil.com
  Login,mylogin
  Password,mypassword
 
  My script using the CSV module is:
  require 'csv'
  array=[]
  CSV::Reader.parse(File.open(file.csv)){|row| array  row[1]}
 
  The above code saves the Values in column two into an array. I use
  the
  array elements in my script.
 
  IN the same way, is there a method to create a Hash table. I would
  like to access the values in column 2 using the Key on column 1. I
  want to do this, as the CSV file may keep changing.
  Also how to access the Hash keys(or use them in the script)?
 
  Kindly provide guidance.
  Thank you
 
  Margam
  

 


--~--~-~--~~~---~--~~
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: Authentication Popups

2009-01-14 Thread gem dandy

Amit,

This is the method that works for me:

***
require 'watir/ie'
require 'watir/WindowHelper'
require 'test/unit'
require 'win32ole'
require 'watir\contrib\enabled_popup'


# open a browser
$ie = Watir::IE.new

puts  Step   1: go to the YourUrlt
$ie.goto YourUrl.com

# Use the click_no_wait method immediately proceeding the popup.
# Below is an example
$ie.frame(:index, 3).frame(:index, 2).link(:text,
'Access').click_no_wait

puts  Step   2: handle authentication/login popup using 'AutoIt' 

# On one of my slower PC, the sleeps were needed to make this work.
# You may or may not need them

Watir.autoit.WinWait('Connect to YourPopupName')
Watir.autoit.Send('YourUsername')
sleep 2
Watir.autoit.Send('{TAB}')
sleep 1
Watir.autoit.Send('YourPassword')
sleep 1
Watir.autoit.Send('{ENTER}')
sleep 3

$ie.close

**

Darryl (gem dandy) Brown

On Jan 14, 2:02 pm, aami...@gmail.com wrote:
 Is there any way through which i can handle the Authentication popups?
 The Solution mentioned at the following link doesn't seem to work for
 me:http://wiki.openqa.org/display/WTR/Basic+Authentication

 Thanks in Advance.

 Regards,
 Amit
--~--~-~--~~~---~--~~
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] Test Results output capturing

2009-01-14 Thread Jagdeep Jain

I want to populate Watir results to HTML format. Is there any way to
do this?
Or is there any way to have all 'puts' goes to HTML file?


--~--~-~--~~~---~--~~
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: Test Results output capturing

2009-01-14 Thread Jagdeep Jain


I got it through Rspec:
spec usingrspec.rb --format html  testresult.html


On Jan 15, 11:31 am, Jagdeep Jain jagdeep.j...@gmail.com wrote:
 I want to populate Watir results to HTML format. Is there any way to
 do this?
 Or is there any way to have all 'puts' goes to HTML file?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---