Re: [Wtr-general] Identifying "Last" object using Index: -1 ???

2007-02-07 Thread carl . l . shaulis




Howdy,

I am not sure this will help.  Here is an example of how we have been able
to locate data in table cells.

Create a file called MSNTest.rb with this code:

# CLS February 7,2007  Example for finding table data
  #includes:
require 'watir'   # the watir controller
require "rexml/document"
require "date"
require '/apps/ruby/lib/ruby/1.8/test/unit'
require '/apps/ruby/lib/ruby/1.8/test/unit/ui/console/testrunner'
require 'watir/testUnitAddons'
require 'watir/WindowHelper'
require '/Apps/watir_bonus/examples/Stuff.rb'
include REXML
include Watir
include Stuff

   puts "## Begin Test - MSN Table Test"



class MSN_Test < Test::Unit::TestCase
include Watir


   def setup
   @ie = IE.new
   @ie.goto("http://www.msn.com";)

   end

   def test1

assert(@ie.link(:text, "Sports").exists?)

 #   @ie.show_all_objects

   @ie.show_tables

   Table.new(@ie.table(:index, 1)).printPretty
   end
end

#

#
# END - MSN test

In the same directory create a file called Stuff.rb with this code:


# This module uses REXML to parse the XML.
# REXML is available at http://www.germane-software.com/software/rexml/
require "rexml/document"
require "date"
include REXML

# There is no need for the test to require or include REXML.
module Stuff

  # The Table class provides convenience methods for accessing data in
  # WATIR tables
  class Table
#The constructor for Table takes a WATIR table and
# assigns it to the instance variable @table
def initialize(table)
@table = table
end

#Takes a string and two integers. Returns the contents of
# the table cell at the index of the second integer for the
# row where the string is in the cell at the index of the
# first integer.
# Example: myTable.assoc("findMe",2,4) finds the row of
#  the table where the text "findMe" is in the second column,
#  and returns the contents of the 4th column
def assoc(text,rowFinder,targetCell)
  @table.each { |row|
if row[rowFinder].to_s.include? text
  return row[targetCell].to_s
end
  }
  return nil
end

def printPretty()
  rows = 0
  @table.each { |row|
rows += 1
puts "row " + rows.to_s + ":"
print "\t"
cells = 0
row.each { |cell|
  cells += 1
  print "cell " + cells.to_s + ": [" + cell.to_s + "]\t"
}
print "\n"
  }
  puts
"-"
end

  end
end

Execute the MSNTest..rb script to see the results of the content of the
table on the MSN home page.  This site happens to only have one table, but
if there were multiple tables just use the index value of the table your
target data resides (Table.new(@ie.table(:index, ??)).printPretty).

Good luck,

Carl





http://forums.openqa.org/thread.jspa?threadID=6471&messageID=18349#18349




___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] A Different WIN32OLERuntimeError (Ruby)

2007-02-07 Thread Bernard Kenik
I know that I am a newcomer to this thread...so please excuse the buttin.

I do not seem to have any problem starting Internet Explorer using ruby.

>> require 'win32ole'
=> true
>> ie = WIN32OLE.new("InternetExplorer.Application")
=> #(WIN32OLE:0x312facc)
>> ie.visbible = TRUE
=> true

an empty IE window shows up when I click on the Windows Internet tab at the 
bottom of my screen.

This occurs wether or not there is another instance of IE running.

I am using ruby 1.8.5 (2006--12-25 patchlevel 12) [i386-mswin32]
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6470&messageID=18360#18360
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


[Wtr-general] jscript_test.rb doesn't work in my machine.

2007-02-07 Thread barry
Jscript_test.rb doesn't work in my machine. Watir is not able to click on the 
OK button to dismiss the first javascript alert/popup. Any clue?
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6473&messageID=18359#18359
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


[Wtr-general] concurrent tests with cookie / session handling?

2007-02-07 Thread Chris Harris
I am a newbie to this, so bear with me here...

I have a test that I need to run concurrently with each browser using a 
different cookie from the test site.

Is this possible with Watir?  If so, any tips on how to handle the cookie 
aspect of things?

Thanks
Chris___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] WIN32OLERuntimeError

2007-02-07 Thread HarryC
This is my code. However, this strange error happens even for the simplest 
scenario. 



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

include Watir

class TC_NTMS_LOGIN < Test::Unit::TestCase 

def setup()
@ie = Watir::IE.start("localhost/NTMS/index.aspx")
if (@ie.contains_text(/Welcome! You are currently signed in 
as/))
@ie.link(:id, 'ctl00_MainContent_lbtnLogOut').click
end 
end

def teardown()
@ie.close
end

def test_thud1_login()
@ie.text_field(:id, 
'ctl00_MainContent_txtUserName').set('thud1')
@ie.text_field(:id, 
'ctl00_MainContent_txtPassword').set('PASSWORD')
@ie.button(:id, 'ctl00_MainContent_btnLogin').click

assert(@ie.contains_text('Report Page'))

end

def test_thud2_login()
@ie.text_field(:id, 
'ctl00_MainContent_txtUserName').set('thud2')
@ie.text_field(:id, 
'ctl00_MainContent_txtPassword').set('PASSWORD')
@ie.button(:id, 'ctl00_MainContent_btnLogin').click

assert(@ie.title =~ /NTMS - Welcome/, 'thud2 should be 
redirected to Welcome page')

end

def test_thud1_login_and_logout()
@ie.text_field(:id, 
'ctl00_MainContent_txtUserName').set('thud1')
@ie.text_field(:id, 
'ctl00_MainContent_txtPassword').set('PASSWORD')
@ie.button(:id, 'ctl00_MainContent_btnLogin').click
@ie.link(:id, 'ctl00_hplHome').click
assert(@ie.contains_text(/Welcome! You are currently signed in 
as thud1/), 'should contains welcome info')
@ie.link(:id, 'ctl00_MainContent_lbtnLogOut').click
assert([EMAIL PROTECTED](/Welcome! You are currently signed in 
as thud1/), 'should not contains welcome info')

end

def test_links()
@ie.link(:id, 'ctl00_hplHome').click
assert(@ie.title =~ /NTMS - Welcome to/, 'title should be NTMS 
- Welcome ...')
@ie.link(:url, 
'http://localhost/NTMS/register/forgot.aspx').click
assert(@ie.title =~ /Request Account Information/, 'title 
should be NTMS - Request Account Information ...')
@ie.link(:id, 'ctl00_hplHome').click
@ie.link(:url, 
'http://localhost/NTMS/register/index.aspx').click
assert(@ie.title =~ /Register/, 'title should be NTMS - 
Register ...')
end 

def test_quick_search()

@ie.text_field(:id, 'ctl00_MainContent_txtTickNumber').set('4')
@ie.select_list(:id, 
'ctl00_MainContent_ddlStatesQuick').select('DE')
@ie.button(:id, 'ctl00_MainContent_btnQuickSearch').click

assert(@ie.title =~ /Search/, 'title should be NTMS - Search 
...')
end 

end
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6466&messageID=18357#18357
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] WIN32OLERuntimeError

2007-02-07 Thread HarryC
Yes, I update my Windows quite often. I do a lot of .NET works, so my machine 
is full of .NET framework stuff.

I have full admin right.

Anyway, if anyone has the same problem, just manually open a browser window 
first (or have a batch file open the browser).
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6466&messageID=18358#18358
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] renaming sheets in Excel

2007-02-07 Thread alan
Well they just changed the requirement on what they want me to output to Excel, 
so I'm shelving this for awhile, but I'll still watch the replies.
i couldn't get nchristie's example to work but that could be more me than 
anything. But it looks promising so thank you.
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6472&messageID=18353#18353
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] renaming sheets in Excel

2007-02-07 Thread alan
The rubygarden page is what got me started on the whole excel thing :)
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6472&messageID=18351#18351
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] A Different WIN32OLERuntimeError (Ruby)

2007-02-07 Thread Chris McMahon
> If i only i could. The problem is that i myself snarfed the code from
> Alexey Verkhovsky, so he's the one to ask.
>
> Or you could check out the pickaxe book...

I don't think it's in the Pickaxe.  That's some deep Win32 API magic.
-C
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] File location installing 1.4.1 Gem

2007-02-07 Thread Bret Pettichord
[EMAIL PROTECTED] wrote:
> Here is where I get more confused.  The unit tests all_tests_concurrent.rb
> fails.  The errors seem to occur on the checkbox_test.rb and
> buttons_test.rb.  If I execute button_tests.rb and checkbox_test,rb in
> isolation those tests works perfectly.   Has anyone resolved the issues
> regarding all_tests_concurrent.rb?  The errors are below.
>   
These comments are included in all_tests_concurrent.rb:

# This is an UNFINISHED attempt to run the unit tests currently.
# The work on the harness is complete.
# The problem remaining is that the tests are not thread-safe.
# It's an open question whether getting this to work would actually save 
any execution time.

___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] WIN32OLERuntimeError

2007-02-07 Thread Bret Pettichord
Nathan Christie wrote:
> I want to think this may somehow be related to a .NET Framework [automatic?] 
> update that took place at some point. I fear the only solution is a reinstall 
> of Windows.
>   
I suspect that the change could be related to MS security update of some 
kind.

Bret
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] A Different WIN32OLERuntimeError (Ruby)

2007-02-07 Thread Bret Pettichord
Nathan Christie wrote:
> Also, if you have some time, could you add a comment for each line with some 
> explanation. Mostly just curious about:
> [u]startup_info = [68].pack('lx64') 
> process_info = [0, 0, 0, 0].pack('')[/u]
> But I would like to be able to understand the logic, as that code has many 
> new elements I'm not familiar with.
>   
If i only i could. The problem is that i myself snarfed the code from 
Alexey Verkhovsky, so he's the one to ask.

Or you could check out the pickaxe book...

Bret
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] Identifying "Last" object using Index: -1 ???

2007-02-07 Thread Lauren
Thank you so much for all who have responded to my post. However, I still 
haven't been able to identify my object. I have downloaded the Developer 
Toolbar for ie (love it!) and can see the various attributes. My button is 
nested deep within a table. I can identify the table using both ":class" and 
":index", but when I add .button(:what, ever).click I get the follow error:

undefined method `button' for # (NoMethodError)

I have tried different versions such as:

ie.table(:class, 'primaryLarge').button(:name, "SCbutton").click
ie.table(:index, 10). button(:name, "SCbutton").click

Any more thoughts to help me out? I have been stuck here trying to identify 
this object for a really long time now! :/

Thanks again to all who posted!
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6471&messageID=18349#18349
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] renaming sheets in Excel

2007-02-07 Thread Paul Carvalho

Hi Alan, I'm interested in the answer to your question but I don't know what
it is.  I suggest reading through this message in the archive:

http://rubyforge.org/pipermail/wtr-general/2006-September/007592.html

Let us know what you find out.

Cheers.  Paul C.


On 07/02/07, alan wrote:


Hi,
After searching the forum I have found how to open an Excel spread sheet
and write to it, and how to create a new sheet in the exiting file using :
excelchart = excel.Sheets.Add()

How would I give this sheet a name instead of the default Sheet X name?
Preferably I would name the sheet with the current day's date, which I
think I have figured out how to get date in the script (I use another script
that uses the current date as a user name when creating an account in a web
tool I test).

Thanks

___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] How do I connect to MS SQL 2005 using Ruby?

2007-02-07 Thread Chris McMahon
> Please share the code that you got to work.  I (and I am sure others do
> as well) collect code piece/scripts and tuck them away for possible use
> at a later time.

As Carl mentioned, I have an article in the current Better Software
magazine about mucking around in databases using Ruby ODBC.   Back
issues are US $15.00, subscriptions are $75.00.   Or if you're really
persuasive, I could send a PDF.  But if you're interested, I'd prefer
that you do business with the Better Software people, because they do
good work.   http://www.stickyminds.com/BetterSoftware/magazine.asp
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] How do I connect to MS SQL 2005 using Ruby?

2007-02-07 Thread Chris McMahon
On 2/7/07, Nathan <[EMAIL PROTECTED]> wrote:
> So here's what I've done - first created an ODBC data source connection in my 
> Adminstrative Tools.  Now I'm in irb, and I connected like conn = 
> ODBC.connect("qastats","uname","pass")
>
> Then I did h = conn.prepare("SELECT * FROM table_name")
>
> And now h doesn't seem to have anything in it, but my table does contain info.
>
> This is MS SQL, any idea what's wrong?

h = conn.run("SELECT * FROM table_name")
rows = h.fetch_all

rows.each do |row|
  puts row
  end
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] How do I connect to MS SQL 2005 using Ruby?

2007-02-07 Thread Nathan
So here's what I've done - first created an ODBC data source connection in my 
Adminstrative Tools.  Now I'm in irb, and I connected like conn = 
ODBC.connect("qastats","uname","pass")

Then I did h = conn.prepare("SELECT * FROM table_name")

And now h doesn't seem to have anything in it, but my table does contain info.

This is MS SQL, any idea what's wrong?

Nathan
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6445&messageID=18343#18343
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] renaming sheets in Excel

2007-02-07 Thread John Lolis
Heres a link i found useful when i was going using Excel

http://wiki.rubygarden.org/Ruby/page/show/ScriptingExcel
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6472&messageID=18341#18341
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] renaming sheets in Excel

2007-02-07 Thread Nathan Christie
One way to do it, once you identify your instance of Excel, say, as "myExcel", 
you can modify them as such: (note that the numbers correspond to the workbook 
number, determined by the order it was created / opened and the actual 
worksheet tab at the bottom, respectively, which Excel considers a collection, 
one-based)

myExcel = WIN32OLE::new( "Excel.Application" )
myExcel.Workbooks.Open( myFilePath + myInputFileName )
myExcel.Workbooks( 1 ).Worksheets( 1 ).name = "Custom Sheet Name"

Deleting them like this if you want:
@@ExcelOutput.Workbooks( 1 ).Worksheets( 3 ).delete()

There is no WIN32API method for simultanesouly creating and naming a new 
worksheet.

Hope this helps,
Nathan Christie
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6472&messageID=18339#18339
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] How do I connect to MS SQL 2005 using Ruby?

2007-02-07 Thread Cain, Mark
For those of us that have been following this thread...

Please share the code that you got to work.  I (and I am sure others do
as well) collect code piece/scripts and tuck them away for possible use
at a later time.  Many of the solutions I have today have been gathered
piecemeal over months of hearing how others solved similar issues.  It
is one of the great strengths of this forum! 

Thanks in advance,

--Mark


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Chris McMahon
Sent: Wednesday, February 07, 2007 1:52 PM
To: wtr-general@rubyforge.org
Subject: Re: [Wtr-general] How do I connect to MS SQL 2005 using Ruby?

On 2/7/07, Nathan <[EMAIL PROTECTED]> wrote:
> So I have a connection now!  And that was my goal, but it doesn't act
the same way as the MySQL gem.  For example, I don't see a query
method/object anywhere.  I guess I'm just going to need to do a little
searching.  What a pain.

data = connection.run("SELECT name, giblets FROM members M, balance B
WHERE M.active = 'N' AND M.id =
B.member_id")
records = data.fetch_all

Read the docs:   http://www.ch-werner.de/rubyodbc/odbc.html
Seriously.  :)
-C
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] How do I connect to MS SQL 2005 using Ruby?

2007-02-07 Thread Chris McMahon
On 2/7/07, Nathan <[EMAIL PROTECTED]> wrote:
> So I have a connection now!  And that was my goal, but it doesn't act the 
> same way as the MySQL gem.  For example, I don't see a query method/object 
> anywhere.  I guess I'm just going to need to do a little searching.  What a 
> pain.

data = connection.run("SELECT name, giblets FROM
members M, balance B WHERE M.active = 'N' AND M.id =
B.member_id")
records = data.fetch_all

Read the docs:   http://www.ch-werner.de/rubyodbc/odbc.html
Seriously.  :)
-C
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] renaming sheets in Excel

2007-02-07 Thread Nathan Christie
Yes! This was one of the first resources for scripting Excel via Ruby and has 
served me well. I highly second this recommendation for anyone doing anything 
of the sort.
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6472&messageID=18342#18342
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] How do I connect to MS SQL 2005 using Ruby?

2007-02-07 Thread Nathan
So I have a connection now!  And that was my goal, but it doesn't act the same 
way as the MySQL gem.  For example, I don't see a query method/object anywhere. 
 I guess I'm just going to need to do a little searching.  What a pain.

Any other quick start tips would be great.

Thanks,

Nathan
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6445&messageID=18340#18340
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


[Wtr-general] renaming sheets in Excel

2007-02-07 Thread alan
Hi,
After searching the forum I have found how to open an Excel spread sheet and 
write to it, and how to create a new sheet in the exiting file using :
excelchart = excel.Sheets.Add()

How would I give this sheet a name instead of the default Sheet X name?
Preferably I would name the sheet with the current day's date, which I think I 
have figured out how to get date in the script (I use another script that uses 
the current date as a user name when creating an account in a web tool I test).

Thanks
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6472&messageID=18338#18338
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] A Different WIN32OLERuntimeError (Ruby)

2007-02-07 Thread Nathan Christie
That's awesome stuff Bret. I will most likely utilize some form of this 
workaround to remove the annoyance of having to ensure iexplore.exe is started. 
Just curious, where is the documentation that [i]you[/i] use for these Win32API 
functions?

Also, if you have some time, could you add a comment for each line with some 
explanation. Mostly just curious about:
[u]startup_info = [68].pack('lx64') 
process_info = [0, 0, 0, 0].pack('')[/u]
But I would like to be able to understand the logic, as that code has many new 
elements I'm not familiar with.

Thanks so much!
Nathan Christie
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6470&messageID=18337#18337
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] Identifying "Last" object using Index: -1 ???

2007-02-07 Thread Charley Baker

Does it have an id, name, or some text? Anything that's identifiable? You
can certainly find it's index by poking through the dom using ie's dom
explorer:
http://www.microsoft.com/downloads/details.aspx?FamilyID=E59C3964-672D-4511-BB3E-2D5E1DB91038&displaylang=en

-Charley

On 2/7/07, Lauren <[EMAIL PROTECTED]> wrote:


Hello Everyone,

I am having trouble identifying an object in my web app. After trying
several different attempts with ie.button I wanted to revert to:
ie.button(:index, x).click the problem is that there can be any number of
buttons before my button is reached. The button I want to identify is the
last button on the page so I thought that I would try the brilliant idea of:
ie.button(:index, -1).click However, this is not working either.

My button is nested in a table. Any thoughts on how I can access/identify
this object using 'index' or something else.

Thanks for your help!
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6471&messageID=18330#18330
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] Identifying "Last" object using Index: -1 ???

2007-02-07 Thread John Lolis
Another option is to locate it within the table.

ie.table(:what, ever).button(:index,number)
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6471&messageID=18335#18335
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] Identifying "Last" object using Index: -1 ???

2007-02-07 Thread Ravi
Try:

ie.button(:index,ie.buttons.length).click

-Ravi
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6471&messageID=18331#18331
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] A Different WIN32OLERuntimeError (Ruby)

2007-02-07 Thread Bret Pettichord
One workaround would be to use ruby to start an iexplore process first.

class IEProcess
  def self.start
startup_info = [68].pack('lx64')
process_info = [0, 0, 0, 0].pack('')
   
# TODO: make this portable
startup_command = 'C:\Program Files\Internet Explorer\IEXPLORE.EXE'
   
result = Win32API.new('kernel32.dll', 'CreateProcess', 'pplppp', 
'l').
  call(
   nil,
   startup_command,
   0, 0, 1, 0, 0, '.', startup_info, process_info)
   
# TODO print the error code, or better yet a text message
raise "Failed to start IEXPLORE." if result == 0
   
process_id = process_info.unpack('')[2]
puts "Process ID: #{process_id}"
self.new process_id
  end
end
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] A Different WIN32OLERuntimeError (Ruby)

2007-02-07 Thread Paul Carvalho

Ah.  Thanks for the info.  I haven't noticed that problem/error before on my
system that's running Ruby 184-20 and Watir 1.4.1, so I never really looked
closely at what the underlying calls are.

As far as I'm concerned, if it works don't look any further. ;-)

Good luck.  Paul C.


On 07/02/07, Nathan Christie <[EMAIL PROTECTED]> wrote:


When I use this Watir command you have suggested, it unwraps it and sends
essentially the WIN32OLE command to create a new IE instance, so in turn:

[ myIE = IE.new() ] == [ myIE = WIN32OLE::new( "
InternetExplorer.Application" ) ]

So this Watir command: `IE.new()` does this:
IE.new() —› IE object constructor: `initialize()`
—› `initialize()` calls `create_browser_window()` —›
`create_browser_window()` executes this command: [EMAIL PROTECTED] = 
WIN32OLE.new('
InternetExplorer.Application')`

Having used Ruby's WIN32OLE library for some years to automate MS apps, I
wanted to see what the error would be like if I used that code. The error
you get back from Watir is different and IMO not as informative as the one
you get from Ruby when executing the initialization code that throws the
error.

___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

[Wtr-general] Identifying "Last" object using Index: -1 ???

2007-02-07 Thread Lauren
Hello Everyone,

I am having trouble identifying an object in my web app. After trying several 
different attempts with ie.button I wanted to revert to: ie.button(:index, 
x).click the problem is that there can be any number of buttons before my 
button is reached. The button I want to identify is the last button on the page 
so I thought that I would try the brilliant idea of: ie.button(:index, 
-1).click However, this is not working either. 

My button is nested in a table. Any thoughts on how I can access/identify this 
object using 'index' or something else. 

Thanks for your help!
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6471&messageID=18330#18330
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] A Different WIN32OLERuntimeError (Ruby)

2007-02-07 Thread Nathan Christie
When I use this Watir command you have suggested, it unwraps it and sends 
essentially the WIN32OLE command to create a new IE instance, so in turn:

[ myIE = IE.new() ] == [ myIE = WIN32OLE::new( "InternetExplorer.Application" ) 
]

So this Watir command: `IE.new()` does this:
IE.new() —› IE object constructor: `initialize()` —› 
`initialize()` calls `create_browser_window()` —› 
`create_browser_window()` executes this command: [EMAIL PROTECTED] = 
WIN32OLE.new('InternetExplorer.Application')`

Having used Ruby's WIN32OLE library for some years to automate MS apps, I 
wanted to see what the error would be like if I used that code. The error you 
get back from Watir is different and IMO not as informative as the one you get 
from Ruby when executing the initialization code that throws the error.
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6470&messageID=18329#18329
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] A Different WIN32OLERuntimeError (Ruby)

2007-02-07 Thread Paul Carvalho

Why don't you just use the Watir command to do this?  Am I missing
something?


myIE = IE.new



Nathan Christie wrote:


[b]irb(main):002:0> myIE = WIN32OLE.new( "InternetExplorer.Application" )

___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] A Different WIN32OLERuntimeError (Ruby)

2007-02-07 Thread Nathan Christie
This is the same error as "WIN32OLERuntimeError", but this info is what Watir 
would send to Ruby.
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6470&messageID=18323#18323
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] File location installing 1.4.1 Gem

2007-02-07 Thread Bret Pettichord
[EMAIL PROTECTED] wrote:
> Ruby is installed at c:\apps.  I then place the watir 1.4.1 gem in
> c:\apps\ruby.  Using a command prompt I navigate to c:\apps\ruby then type
> gem install watir 1.4.1.
>   
It doesn't matter what your current directory is when you type the command.

What matters is what version of ruby the gem command is using -- that is 
the one that is used and will be updated with the contents of the new gem.
> I do not know much about how gems are generated or installed, but my
> observation is that when installing the watir 1.4.1 gem the html files are
> placed in c:/Program Files/Watir/unittests/html/.
>   
That is where the one-click installer puts them.

Gems should be installed in

C:/ruby/lib/ruby/gems/1.8/gems/watir-1.4.1


___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] WIN32OLERuntimeError

2007-02-07 Thread Nathan Christie
I didn't fully read this thread, this is exactly what is happening to me, I 
traced the to the Ruby level in my post, "A Different WIN32OLERuntimeError", 
even though it is exactly the same problem this gentleman is having =|

I want to think this may somehow be related to a .NET Framework [automatic?] 
update that took place at some point. I fear the only solution is a reinstall 
of Windows.

Let's dig deeper!
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6466&messageID=18322#18322
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


[Wtr-general] A Different WIN32OLERuntimeError (Ruby)

2007-02-07 Thread Nathan Christie
Ok everyone, if you can find a solution to this annoyance I will be extremely 
happy. Here is the scenario, when I initially installed Ruby/Watir on my 
machine it worked great. At some point some configuration was changed/software 
was installed/etc and now I am encountering this error:

Configuration: WinXP Pro, Ruby v1.8.5, Watir 1.4.1

[u]Scenario 1[/u]:
Assumption(s): no `iexplore.exe` processes are running
If I try to instantiate an InternetExplorer object via Ruby, I get the 
following error:
[b]irb(main):002:0> myIE = WIN32OLE.new( "InternetExplorer.Application" )
WIN32OLERuntimeError: failed to create WIN32OLE object from 
`InternetExplorer.Application'
HRESULT error code:0x80070003
  The system cannot find the path specified.
from (irb):2:in `initialize'
from (irb):2:in `new'
from (irb):2[/b]

[u]Scenario 2[/u]:
Assumption(s): at least one `iexplore.exe` process is running
Now I am able to execute the exact same command and it works perfectly.

I realize this may be slightly out of the realm of Watir expertise, as it seems 
to be a general Ruby / WIN32OLE error; however, I encounter this error when 
running Watir's IE object initialization methods.

A few resolutions I have tried already:
1) completely uninstall Ruby & Watir > reinstall
2) tried several different `win32ole.c` files
3) smash keyboard with closed fists and banging mouse against desk

None of them seemed to make any difference. Even after a clean install the same 
error exists. I can get around this by making sure an `iexplore.exe` instance 
is running before kicking off any of my scripts from my local machine; however, 
that is undesireable and I am curious regarding the nature of the error.

Another note that may be of use is the fact that this error does not happen on 
any of my coworker's machines. I have configured Ruby/Watir on several other QA 
staff machines to kick of automation, and it works fine there – 
regardless of whether an instance of `iexplore.exe` is running or not. 

I would love a solution that didn't involve reinstalling Windows in any shape.

If anyone can shed some light on this mysterious occurance I would really 
appreciate it.

Thanks,
Nathan Christie
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6470&messageID=18321#18321
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] WIN32OLERuntimeError

2007-02-07 Thread John Lolis
Post your code, I'm willing to bet that you are doing something out of order.
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6466&messageID=18316#18316
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] WIN32OLERuntimeError

2007-02-07 Thread Bret Pettichord
HarryC wrote:
> I found out that if I open a browser window first, the problem will not 
> happen.  However it happens when there is no existing browser window. 
>
> Strange.
It is strange. What OS are you using? Do you have admin rights?

Bret
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] How do I connect to MS SQL 2005 using Ruby?

2007-02-07 Thread Adam Reed
Well, that was the wrong tutorial, it looks like I didn't bookmark the
MS SQL one after all, but if you're looking for MySQL that's a good one
:D 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Adam Reed
Sent: Wednesday, February 07, 2007 9:01 AM
To: wtr-general@rubyforge.org
Subject: Re: [Wtr-general] How do I connect to MS SQL 2005 using Ruby?

Nathan,

This tutorial helped me when I was trying to connect to our
mysql and mssql dbs. 

http://www.kitebird.com/articles/ruby-dbi.html#TOC_7

Thanks,
Adam

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Nathan
Sent: Tuesday, February 06, 2007 3:21 PM
To: wtr-general@rubyforge.org
Subject: [Wtr-general] How do I connect to MS SQL 2005 using Ruby?

Just wondering, because I can't find anything that really makes sense,
and don't want to use full blown out rails if possible, but I need to
connect to MS SQL Server 2005 - does anybody have any thought, ideas, or
solutions?

Thanks,

Nathan
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6445&messageID=18245#18245
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] How do I connect to MS SQL 2005 using Ruby?

2007-02-07 Thread Chris McMahon
> ODBC I know about from developing in Java with JDBC, but whenever they wanted 
> to switch over to Microsoft databases we needed to use ODBC to connect (using 
> Administrative Tools > Data Sources).  Hopefully this will answer my 
> question, and hopefully there will not be a lot to change.

 The cool thing about ODBC is that it is a standard.  In
Windows/MSSQL, you use Administrative Tools > Data Sources to make it
possible to use the standard commands.  For Windows/Oracle, or
whatever, there are ODBC drivers available.  On other platforms like
Linux/PostgreSQL or Linux/MySQL, there are other ways to implement
ODBC.

Using a native database driver is more efficient,  and using the DBI
library is more powerful (I think) but ODBC in my experience is by far
the simplest and most portable way to talk to databases.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] How do I connect to MS SQL 2005 using Ruby?

2007-02-07 Thread Adam Reed
Nathan,

This tutorial helped me when I was trying to connect to our
mysql and mssql dbs. 

http://www.kitebird.com/articles/ruby-dbi.html#TOC_7

Thanks,
Adam

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Nathan
Sent: Tuesday, February 06, 2007 3:21 PM
To: wtr-general@rubyforge.org
Subject: [Wtr-general] How do I connect to MS SQL 2005 using Ruby?

Just wondering, because I can't find anything that really makes sense,
and don't want to use full blown out rails if possible, but I need to
connect to MS SQL Server 2005 - does anybody have any thought, ideas, or
solutions?

Thanks,

Nathan
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6445&messageID=18245#18245
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] How do I connect to MS SQL 2005 using Ruby?

2007-02-07 Thread Nathan
Thank you so much.  I didn't think of just require "odbc".  Now I need to get 
my db into MSSQL and try it out.  I'm not testing the database, but rather 
using it to store results of tests.  It was just a requirement from one of our 
lead developers who wanted some performance tests for our website with Watir.  
We already have a MySQL version going, but I didn't see an obvious MSSQL 
adapter anywhere in Ruby, and not in the docs that are installed with Ruby on 
Windows.  ODBC I know about from developing in Java with JDBC, but whenever 
they wanted to switch over to Microsoft databases we needed to use ODBC to 
connect (using Administrative Tools > Data Sources).  Hopefully this will 
answer my question, and hopefully there will not be a lot to change.

As far as Active Record goes, I'm not against it as long as I don't need to be 
running any extra servers (like WeBrick). I'm running my scripts on 
minimalistic WinXP VM images, and they can't handle a lot, nor should they need 
to, PLUS our website is very media heavy, which slows things down anyway. So I 
need a solution that behaves similarly to the MySQL gem.  The obvious, an ODBC 
gem, doesn't seem to exist, but now I know that ODBC is part of Ruby (for 
Windows at least).

Nathan
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6445&messageID=18304#18304
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] WIN32OLERuntimeError

2007-02-07 Thread HarryC
I found out that if I open a browser window first, the problem will not happen. 
 However it happens when there is no existing browser window. 

Strange.
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6466&messageID=18303#18303
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


[Wtr-general] WIN32OLERuntimeError

2007-02-07 Thread HarryC
I need some help here. When I try to do a simple IE.new I keep getting this 
error message. I am using ruby 1.8.5 with Watir 1.4.1

C:/ruby/lib/ruby/gems/1.8/gems/watir-1.4.1/./watir.rb:1176:in `initialize': 
failed to create WIN32OLE object from `InternetExplorer.Application' 
(WIN32OLERuntimeError)
HRESULT error code:0x80070003
  The system cannot find the path specified.from C:/ruby/lib/ruby/ge
ms/1.8/gems/watir-1.4.1/./watir.rb:1176:in `new'
from C:/ruby/lib/ruby/gems/1.8/gems/watir-1.4.1/./watir.rb:1176:in `crea
te_browser_window'
from C:/ruby/lib/ruby/gems/1.8/gems/watir-1.4.1/./watir.rb:1086:in `init
ialize'
from C:/Documents and Settings/hchou/Desktop/test.rb:8:in `new'
from C:/Documents and Settings/hchou/Desktop/test.rb:8
Press any key to continue . . .
-
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6466&messageID=18298#18298
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general