[wtr-general] Re: Hard to get to link

2012-01-18 Thread mdwin01
Thank you, John.

I actually fat fingered something..
ie.link(:text, Map).href
works just fine.

I was thinking that it I had to daisy chain more elements to find what
I was looking for, which is the case if there are forms found on a
specific page, etc.

Have a great day!

-- 
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


[wtr-general] Hard to get to link

2012-01-17 Thread mdwin01
Hi-

Could someone help me get to the link for company address on Yahoo
Finance profile page?

Thank you,

Mark


require 'watir'
ie = Watir::IE.new
ie.goto(http://finance.yahoo.com/q/hp?s=MSFT+Profile;)

#puts ie.link(:xpath,//a[contains(@href,'country=')]/).href
#puts ie.link(:xpath, /html/body/div[3]/div[4]/table[2]/tbody/tr[2]/
td/a).href
#puts ie.link(:url, /country/).href
#puts ie.cell(:class, yfnc_modtitlew1).link(:url, /country/).href

-- 
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


[wtr-general] IE File Download

2012-01-02 Thread mdwin01
Hi-

I followed Zeljko's examples on 
http://wiki.openqa.org/display/WTR/File+Downloads
to implement File Downloads from Internet Explorer.  In my script (see
below) once I get File Download popup, I tell it to focus on Save
buton, and then click it.  I tried identifying Save button using
Save
[CLASS:Button; INSTANCE:2])
Save

It works, but inconsistently -- every now and then, when looping and
downloading maybe 5 files, my scripts get stuck at the File Download
popup, where Cancel button seems to be in focus.

I'm using:
ruby 1.8.7
watir 2.0.4
autoit v3.3.6.1 (32-bit)
IE 8.0 (32-bit)
Windows 7 (64-bit)


Any help would be appreciated,

-Mark


def save_file(filepath)
puts Saving #{filepath}
ai = WIN32OLE.new(AutoItX3.Control)

ai.WinWait(File Download, , 5) # 1) File Download, click Save
ai.ControlFocus(File Download, , [CLASS:Button; INSTANCE:2])
sleep 1
#ai.ControlClick(File Download, Save, left) #
[CLASS:Button; INSTANCE:2] should be same as Save
ai.ControlClick(File Download, , [CLASS:Button; INSTANCE:2],
left)

ai.WinWait(Save As, , 5) # 2) Save As, click Save
sleep 1
ai.ControlSend(Save As, , Edit1, filepath)
ai.ControlClick(Save As, , Save, left)

ai.WinWait(Confirm Save As, , 5) # 3) Confirm Save As, click Yes
(if file already exists)
ai.ControlClick(Confirm Save As, , Yes)

ai.WinWait(Download complete, , 5)  # 4) Download complete, click
Close
ai.ControlClick(Download complete, , Close)
puts Download complete
end


save_file(file) # call save_file form a loop, pass in file name

-- 
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


[wtr-general] Re: no such file to load -- watir/ie (LoadError)

2011-12-28 Thread mdwin01
Hi Željko, thank you for getting back to me.  I get the following with
Watir::Browser.new:

C:\ruby\XLSirb
irb(main):001:0 require 'watir'
= true
irb(main):002:0 Watir::Browser.new
StandardError: Error in the default values: :browser's value must be
one of 'safari', 'firefox', or
'ie', and '' doesn't look right.
from c:/ruby/lib/ruby/gems/1.8/gems/s4t-utils-1.0.4/lib/s4t-
utils/claims.rb:24:in `user_is_b
ewildered'
from c:/ruby/lib/ruby/gems/1.8/gems/s4t-utils-1.0.4/lib/s4t-
utils/claims.rb:9:in `user_claim
s'

On Dec 28, 5:30 am, Željko Filipin zeljko.fili...@wa-research.ch
wrote:
 On Wed, Dec 28, 2011 at 5:02 AM, mdwin01 mdwi...@gmail.com wrote:
  Watir::IE.new

 What happens if you do this instead of Watir::IE.new?

 Watir::Browser.new

 Željko

-- 
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


[wtr-general] Re: no such file to load -- watir/ie (LoadError)

2011-12-28 Thread mdwin01
Hi Jarmo,

I have the following

require 'xls'
require 'rubygems'
require 'watir'
require 'test/unit'


On Dec 28, 7:19 am, Jarmo Pertman jarm...@gmail.com wrote:
 What require statements do you have in your scripts?

 Jarmo

 On Dec 28, 1:30 pm, Željko Filipin zeljko.fili...@wa-research.ch
 wrote:



  On Wed, Dec 28, 2011 at 5:02 AM, mdwin01 mdwi...@gmail.com wrote:
   Watir::IE.new

  What happens if you do this instead of Watir::IE.new?

  Watir::Browser.new

  Željko- Hide quoted text -

 - Show quoted text -

-- 
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


[wtr-general] Re: no such file to load -- watir/ie (LoadError)

2011-12-28 Thread mdwin01
Hi Chuck, here are the gems and their versions:

C:\ruby\XLSgem list

*** LOCAL GEMS ***

activesupport (2.3.5)
builder (2.1.2)
commonwatir (2.0.4, 1.6.5)
diff-lcs (1.1.2)
ffi (1.0.11)
firewatir (1.6.5)
fxri (0.3.6)
fxruby (1.6.12 mswin32)
gemcutter (0.7.1)
hoe (2.5.0)
hpricot (0.6 mswin32)
json_pure (1.2.0)
log4r (1.0.5)
mechanize (1.0.0)
nokogiri (1.4.1 x86-mswin32)
rake (0.8.7, 0.7.3)
rasta (0.1.10 x86-mswin32-60)
rautomation (0.6.3)
rdiscount (1.6.8)
rspec (2.5.0)
rspec-core (2.5.1)
rspec-expectations (2.5.0)
rspec-mocks (2.5.0)
rubyforge (2.0.3)
rubygems-update (1.8.13)
s4t-utils (1.0.4)
sources (0.0.1)
user-choices (1.1.6.1)
watir (2.0.4)
win32-api (1.4.8 x86-mingw32, 1.4.5 x86-mswin32-60, 1.0.4 mswin32)
win32-clipboard (0.4.3)
win32-dir (0.3.2)
win32-eventlog (0.4.6)
win32-file (0.5.4)
win32-file-stat (1.2.7)
win32-process (0.6.2, 0.5.3)
win32-sapi (0.1.4)
win32-sound (0.4.1)
windows-api (0.4.0, 0.2.0)
windows-pr (1.2.1, 1.0.8, 0.7.2)
xml-simple (1.0.12)


On Dec 28, 9:48 am, Chuck van der Linden sqa...@gmail.com wrote:
 Also, in addition to what Jarmo and Zeljko are asking,  do a 'gem
 list' from the command line so we get a list of all installed gems and
 their versions, it would be good to make sure of the versions of other
 gems watir uses or generally installs (like commonwatir)

 On Dec 28, 5:19 am, Jarmo Pertman jarm...@gmail.com wrote:



  What require statements do you have in your scripts?

  Jarmo

  On Dec 28, 1:30 pm, Željko Filipin zeljko.fili...@wa-research.ch
  wrote:

   On Wed, Dec 28, 2011 at 5:02 AM, mdwin01 mdwi...@gmail.com wrote:
Watir::IE.new

   What happens if you do this instead of Watir::IE.new?

   Watir::Browser.new

   Željko- Hide quoted text -

 - Show quoted text -

-- 
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


[wtr-general] Re: no such file to load -- watir/ie (LoadError)

2011-12-28 Thread mdwin01
Chuck, I ran
gem uninstall commonwatir -v 1.6.5
but still getting same errors.

Please scroll up to see my replies to Jarmo and Zeljko.

Thank you,

Mark

On Dec 28, 11:14 am, Chuck van der Linden sqa...@gmail.com wrote:
 gem uninstall commonwatir -v 1.6.5

 See if that fixes or changes the error.   Also as Zeljko suggests try
 using

 Watir::Browser.new   instead of  Watir::IE.new

 If that does not work, show us what you have for require statments etc
 at the top of your script..

 You might also try updating to a newer version of Ruby (1.9.2) , but I
 don't think that's the problem, so I'd wait to do that after you get
 things working.  (1.8.7 is getting a little behind the times at this
 point, and a lot of materials and other things you will find from this
 point forward are likely to presume 1.9.x versions of Ruby)

 On Dec 28, 7:53 am, mdwin01 mdwi...@gmail.com wrote:



  Hi Chuck, here are the gems and their versions:

  C:\ruby\XLSgem list

  *** LOCAL GEMS ***

  activesupport (2.3.5)
  builder (2.1.2)
  commonwatir (2.0.4, 1.6.5)
  diff-lcs (1.1.2)
  ffi (1.0.11)
  firewatir (1.6.5)
  fxri (0.3.6)
  fxruby (1.6.12 mswin32)
  gemcutter (0.7.1)
  hoe (2.5.0)
  hpricot (0.6 mswin32)
  json_pure (1.2.0)
  log4r (1.0.5)
  mechanize (1.0.0)
  nokogiri (1.4.1 x86-mswin32)
  rake (0.8.7, 0.7.3)
  rasta (0.1.10 x86-mswin32-60)
  rautomation (0.6.3)
  rdiscount (1.6.8)
  rspec (2.5.0)
  rspec-core (2.5.1)
  rspec-expectations (2.5.0)
  rspec-mocks (2.5.0)
  rubyforge (2.0.3)
  rubygems-update (1.8.13)
  s4t-utils (1.0.4)
  sources (0.0.1)
  user-choices (1.1.6.1)
  watir (2.0.4)
  win32-api (1.4.8 x86-mingw32, 1.4.5 x86-mswin32-60, 1.0.4 mswin32)
  win32-clipboard (0.4.3)
  win32-dir (0.3.2)
  win32-eventlog (0.4.6)
  win32-file (0.5.4)
  win32-file-stat (1.2.7)
  win32-process (0.6.2, 0.5.3)
  win32-sapi (0.1.4)
  win32-sound (0.4.1)
  windows-api (0.4.0, 0.2.0)
  windows-pr (1.2.1, 1.0.8, 0.7.2)
  xml-simple (1.0.12)

  On Dec 28, 9:48 am, Chuck van der Linden sqa...@gmail.com wrote:

   Also, in addition to what Jarmo and Zeljko are asking,  do a 'gem
   list' from the command line so we get a list of all installed gems and
   their versions, it would be good to make sure of the versions of other
   gems watir uses or generally installs (like commonwatir)

   On Dec 28, 5:19 am, Jarmo Pertman jarm...@gmail.com wrote:

What require statements do you have in your scripts?

Jarmo

On Dec 28, 1:30 pm, Željko Filipin zeljko.fili...@wa-research.ch
wrote:

 On Wed, Dec 28, 2011 at 5:02 AM, mdwin01 mdwi...@gmail.com wrote:
  Watir::IE.new

 What happens if you do this instead of Watir::IE.new?

 Watir::Browser.new

 Željko- Hide quoted text -

   - Show quoted text -- Hide quoted text -

 - Show quoted text -

-- 
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


[wtr-general] no such file to load -- watir/ie (LoadError)

2011-12-27 Thread mdwin01
Hi-

I set up ruby, gems, watir, and other dependencies on a 2nd computer
and keep on getting:

no such file to load -- watir/ie (LoadError)

as soon as I get to:

Watir::IE.new

in the code.

Of course it all works fine on other computers, with same versions of
ruby and watir.  I've searched this group and the pointers I found
were to update gems and to reinstall watir, which I did.  Others
mentioned bad watir installs with missing ie.rb, but I do have it.
Please see below for what versions of software I have, and what I have
done so far..  Any help would be greatly appreciated!

-Mark


C:\ruby\XLSruby -v
ruby 1.8.7 (2011-02-18 patchlevel 334) [i386-mingw32]

--
C:\ruby\XLSgem update --system
Latest version currently installed. Aborting.

---
C:\ruby\XLSgem uninstall watir

Select gem to uninstall:
 1. watir-1.6.5
 2. watir-2.0.4
 3. All versions
 3
Successfully uninstalled watir-1.6.5
Remove executables:
watir-console

in addition to the gem? [Yn]
Removing watir-console
Successfully uninstalled watir-2.0.4

C:\ruby\XLSgem install watir
Fetching: watir-2.0.4.gem (100%)
Successfully installed watir-2.0.4
1 gem installed
Installing ri documentation for watir-2.0.4...
Installing RDoc documentation for watir-2.0.4...

---

C:\ruby\XLSirb
irb(main):001:0 require 'watir'
= true
irb(main):002:0 Watir::IE.new
LoadError: no such file to load -- watir/ie
from (irb):2

-

C:\ruby\lib\ruby\gems\1.8\gems\watir-2.0.4\lib\watirdir ie*
 Volume in drive C is OS
 Volume Serial Number is 9886-EFC4

 Directory of C:\ruby\lib\ruby\gems\1.8\gems\watir-2.0.4\lib\watir

12/27/2011  09:30 PM32,117 ie-class.rb
12/27/2011  09:30 PM 1,339 ie-process.rb
12/27/2011  09:30 PM   760 ie.rb
12/27/2011  09:30 PMDIR  IEDialog
   3 File(s) 34,216 bytes



-- 
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


[wtr-general] Write to Excel

2011-06-10 Thread mdwin01
Hi-

Can someone help me write to Excel?  I'm using 'xls' Excel interface
to read from excel, but writing to it throws errors:

  1) Error:
test_SearchNews(TC_YahooFinance):
WIN32OLERuntimeError: Range
OLE error code:800A03EC in Unknown
  No Description
HRESULT error code:0x80020009
  Exception occurred.
./xls.rb:263:in `method_missing'
./xls.rb:263:in `write2DArray'
C:/ruby/XLS/SearchNews5.rb:35:in `test_SearchNews'
C:/ruby/XLS/SearchNews5.rb:19:in `each'
C:/ruby/XLS/SearchNews5.rb:19:in `test_SearchNews'


Here's my code:

require 'xls'
require 'watir'
xlFile = XLS.new('C:\MyFile.xlsx') #grab the data file;
myData = xlFile.getRowRecords(Symbol,Sheet1)  #pull data records
from Range, Woksheet

myData.each do |record|

  #Define records in the spreadsheet
  what = record[Symbol]
  #Search news
  if @@ie.text.match(/keyword1/i)
xlFile.write2DArray(1, keyword1, Sheet1)
puts 1 keyword1 found***
  else
puts 0 keyword1 not found
  end
xlFile.close
end


This works:
xlFile.getRowRecords(Symbol,Sheet1) #range, worksheet

This does NOT work:
xlFile.write2DArray(1, keyword1, Sheet1) #value, range,
worksheet

Note that range is just a string found in my Excel sheet, so I have a
column header with Symbol and keyword1

Thank you,

Mark

-- 
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


[wtr-general] Re: relative xpath

2011-05-04 Thread mdwin01
Chuck-

Thank you.  Unfortunetely, indentifying text on the specific row has
its issues - in my specific example, different companies have
different fiscal years, and having to recode my text strings every
three months.

Does nayone know how to code for this:
...go to
http://www.earnings.com/company.asp?client=cbticker=s
scroll down to where you see text Earnings Releases, from there go
down to the next table, 2nd row and get me the the value of the 7th
column.

On May 4, 1:28 pm, Chuck van der Linden sqa...@gmail.com wrote:
 Is there a reason you can't just identify the row based on the text in
 another cell on the same row?

 browser.row(:text, /Q4 2010 Sprint Nextel Corporation Earnings
 Release/).cell(:index, 6).flash

 (presuming 0 based firefox style 'index' values)

-- 
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


[wtr-general] relative xpath

2011-05-03 Thread mdwin01
I'm trying to get to a table cell that has nothing identifable about
it, it's position from the beginning of the page will change, but it's
relative position from a table header stays the same.  I'm using
FireBug to construct my XPath, but whenever I try to make things
relative it gives me object not found..

To see an example, go to
http://www.earnings.com/company.asp?client=cbticker=s
scroll down to where you see text Earnings Releases, from there go
down to the next table, 2nd row and get me the the value of the 7th
column.

@@ie = Watir::IE.start(http://www.earnings.com/company.asp?
client=cbticker=s)
page_html = Nokogiri::HTML.parse(@@ie.html)
#puts page_html.xpath(html/body/table/tbody/tr/td/table[7]/tbody/
tr[3]/td[2]/table[4]/tbody/tr[2]/td/b).inner_text #1)Absolute path to
Earnings releases; works OK
#puts page_html.xpath(//*[contains(text(),'Earnings
Releases')]).inner_text #2)Relative path to Earnings releases;
works OK
#puts page_html.xpath(html/body/table/tbody/tr/td/table[7]/tbody/
tr[3]/td[2]/table[5]/tbody/tr[2]/td[7]/nobr).inner_text #3)Absolute
path to the actual date value 28-Apr-11 7:00 AM; works OK
#puts page_html.xpath(//*[contains(text(),'Earnings Releases')]/
table[1]/tbody/tr[2]/td[7]/nobr).inner_text #4)Relative path to the
actual date value 28-Apr-11 7:00 AM; DOES NOT WORK...

-- 
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


[wtr-general] Re: Skip blank rows

2011-04-20 Thread mdwin01
Thank you, Tiffany!

On Apr 18, 10:26 am, Tiffany Fodor tcfo...@comcast.net wrote:
 Hi!

 You're almost there.

 I use Xls.rb as well and to check for blank rows, I usually use
 something like this:

 myData.each do |record|
   if record['WHERE'] != ''
     ie.frame(:name, main).text_field(:name,
 'account').set(record['WHERE'])
     ie.frame(:name, main).text_field(:name,
 'item').set(record['WHAT'])
   end
 end

 This will skip rows where the 'WHERE' column is blank.

 I can't tell how many rows you're importing from your code, so if
 you're not already, you may want to limit the number of rows you're
 importing from Excel.  I usually bring back about 5-10 rows past where
 my data ends so that if I add a couple more rows, I won't have to
 change the import range from Excel.  You don't want to bring back all
 the rows in the spreadsheet or your framework will need to check each.

 Hope this helps!

 -Tiffany

 On Apr 15, 4:09 pm, mdwin01 mdwi...@gmail.com wrote:



  Hi-

  Could someone help me figure out how to skip over blank Excel rows
  (where the first item in the array is  or length=0) and continue to
  the next row?  I use xls.rb 
  (http://wiki.openqa.org/display/WTR/Excel+interface+class
  ) to read Excel workbook cells that each contain a formula, where
  everything defaults to  or zero length blank.

  Here's a sample xls (note how second to the last row appears blank):
  Import
  WHERE   WHAT
  Account1        Apple

  Account3        Orange

  Here's a snippet of my code:

  require 'xls'
  require 'rubygems'
  require 'watir'

  ie = Watir::IE.attach(:url, 'http://www.blah.com) #reuse existing
  browser window

  #Open Excel file, Import worksheet
  xlFile = XLS.new('C:\MyFile.xls') #grab the data file
  myData = xlFile.getRowRecords('Import','Import')  #pull data records
  from Excel
  xlFile.close

  myData.each do |record|

    #need something that says if record['WHERE'] =  or 0 length then
  skip to next row
    ie.frame(:name, main).text_field(:name,
  'account').set(record['WHERE'])
    ie.frame(:name, main).text_field(:name,
  'item').set(record['WHAT'])

  end- Hide quoted text -

 - Show quoted text -

-- 
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


[wtr-general] Skip blank rows

2011-04-15 Thread mdwin01
Hi-

Could someone help me figure out how to skip over blank Excel rows
(where the first item in the array is  or length=0) and continue to
the next row?  I use xls.rb ( 
http://wiki.openqa.org/display/WTR/Excel+interface+class
) to read Excel workbook cells that each contain a formula, where
everything defaults to  or zero length blank.

Here's a sample xls (note how second to the last row appears blank):
Import
WHERE   WHAT
Account1Apple

Account3Orange



Here's a snippet of my code:

require 'xls'
require 'rubygems'
require 'watir'

ie = Watir::IE.attach(:url, 'http://www.blah.com) #reuse existing
browser window

#Open Excel file, Import worksheet
xlFile = XLS.new('C:\MyFile.xls') #grab the data file
myData = xlFile.getRowRecords('Import','Import')  #pull data records
from Excel
xlFile.close

myData.each do |record|

  #need something that says if record['WHERE'] =  or 0 length then
skip to next row
  ie.frame(:name, main).text_field(:name,
'account').set(record['WHERE'])
  ie.frame(:name, main).text_field(:name,
'item').set(record['WHAT'])

end

-- 
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