Re: [Wtr-general] How to deal with the copyrihgt symbol

2007-07-13 Thread Paul Carvalho

Put the actual copyright symbol in this assert line and it should work:
assert( $ie.text.include?( (c) ) )

When you use the ie.text method, you don't get the source code, you get back
the contents as you see it on the page.  Since you see the *symbol* on the
page (and not copy;), just put what you see into the assert line.

Paul C.


On 12/07/07, jhe [EMAIL PROTECTED] wrote:


Dear all,

Why use the following code always return false, although in the html
document include copy;
assert( $ie.text.include?(copy;) )

Regards,
Jason


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

Re: [Wtr-general] How to deal with the copyrihgt symbol

2007-07-13 Thread Paul Carvalho

On 13/07/07, marekj wrote:


This looks like fun with encoding.



[snip]

Paul suggested to use the actual entity in the assertion. I tried it and it

doesn't work for me. I get false.



It works for me.  I created a ruby script as follows:
-
# Look for the copyright symbol on a page
require 'watir'
require 'test/unit'

class Test_scratch  Test::Unit::TestCase
   def setup
   $ie = Watir::IE.new
   $ie.goto( 'http://www.google.com' )
   end

   def test_copyright
   assert( $ie.text.include?((c)) )
   end

end # o' class


When I run the script I get the following output:

C:\tempruby scratch_copyright_symbol_check.rb
Loaded suite scratch_copyright_symbol_check
Started
.
Finished in 0.734 seconds.

1 tests, 1 assertions, 0 failures, 0 errors


I don't know about you, but that looks like success to me.  If you run the
script above against the Google page, does it fail for you?

Paul C.


(P.S., please remember to CC: the googlegroups address so we can start
moving away from the old rubyforge mailing list.  Thanks.)
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] UnknownObject Exception when running test cases

2007-06-28 Thread Paul Carvalho

If the code below is an actual snippet from your code then could the *order*
the tests be the problem?

Please remember that the _default_ order of execution is ascending alpha, so
the script would likely try to run the tests in the following order
regardless of how they are arranged in the script :
1. test_addAccounts
2. test_login

If the script hasn't logged in *before* you try to add the account, then you
will always get an error.

There are different ways of working around this issue.  You could try
changing the test method names or insert a command to override the order of
test execution.  Check the message archives for details - I didn't find
anything in the FAQ right now for it.

Let us know if that helps.  Cheers.  Paul C.


On 25/06/07, Tiffany Fodor [EMAIL PROTECTED] wrote:


Hi!

I'm creating a test harness that will first collect all of the data
necessary to run the test cases then then execute the test cases.

Here's the code that is calling the test cases:

class TestScript  Test::Unit::TestCase

def test_login
login($producerName, $producerPass)
end

def test_addAccounts
addAccounts($testAccounts)
end
end

The login test works just fine, but the addAccounts test returns the
following:

Watir::Exception::UnknownObjectException: Unable to locate object, using
text and Find Account

This happens no matter what link or field I try to touch.  The same
commands work in the login test.  I've tried using the attach method to
specify what window to use, but that hasn't helped either.


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

Re: [Wtr-general] Save results to file

2007-06-14 Thread Paul Carvalho

Hey B!  Just a few things.

First off, there is a more efficient way of opening a file for writing.  Try
the following instead:

 textlog = File.open(text.log, w)

Secondly, when I run your script, the text.log file is *not* empty.  There
are in fact 70 blank lines in the output file.  That tells me something.  It
tells me that you are correctly opening and writing to the file, but you
just aren't capturing the right information somewhere.

I replaced your link iteration with the following and I got the log file to
list all the URL's:

ie.links.each do |link|
   textlog.puts link.href
end

Is that what you wanted to do?  If not, please post some more details with
what you are looking for and we'll try to help.

Cheers!  Paul C.


On 14/06/07, B Smith [EMAIL PROTECTED] wrote:


I am very close, this finds the links but errors on a variable and the
.txt file is empty




#-#
#
#  I'm  a Pretty Flower Box
#
#
#

##

   require 'watir'   # the watir controller

   # set a variable
   test_site = 'http://www.google.com'
  # set the log file
  textlog = File.open(text.log, File::CREAT|File::APPEND|File::WRONLY)

   # open the IE browser
   ie = Watir::IE.new
   # print some comments
   puts ## Beginning of test: Google search
   puts   
ie.goto(test_site)
puts   Action: entered  + test_site +  in the address bar.
  ie.text_field(:name, q).set(Beer + Bottle + Label)   # q is
the name of the search field
   puts Step 3: click the 'Google Search' button
   ie.button(:name, btnG).click   # btnG is the name of the Search
button
   puts   Action: clicked the Google Search button.

   puts Expected Result: 
   puts  - a Google page with results should be shown.
 puts Iterate thru links on page a pull them into txt file 
 puts Test Passed. Found the test string: 'Beer Bottle Label'.
  ie.links.each do |link| # for each link on the current page in IE...
textlog.puts link.src # print url of the link in the textlog we
created end
# createdtextlog.puts Here's some stuff

   puts ## End of test: Google search
  if ie.contains_text(Beer + Bottle + Label)
  else
  puts Test Failed!
   end
___
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] Concurrent tests, different regions...

2007-06-06 Thread Paul Carvalho

Without seeing more of the code, I'm pretty sure you need to start by moving
away from using Global variables.


On 06/06/07, eisdrache [EMAIL PROTECTED] wrote:


Here is the basic idea of what I am trying to do...

I have one site, lets call it www.example.com. On that site, there is a
login page which directs to four different regions, say
region1.example.com, region2.example.com, etc.



[snip]



I have tried setting up something like this:

php page:

$regions = array('region1','region2','region3','region4');

foreach ($regions as $region) {
$cmd = start example.rbw $region;
exec($cmd);
sleep(3);
}

ruby page:

region = $ARGV[0]

$ie = Watir::IE.start(www.example.com)

$ie.text_field(:name, user).set(username)
$ie.text_field(:name, password).set(password)
$ie.select_list(:name, region).select(region)

proceed with testing...

This, however, does not seem to work. Seems as if two or three instances
will start but only one will actually finish. So, hopefully this makes sense
and hopefully someone can help me figure this one out.

Thanks in advance.

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

Re: [Wtr-general] Long, strange field name issue

2007-05-22 Thread Paul Carvalho

Did you try it with single-quotes instead of double-quotes?


On 22/05/07, Tiffany Fodor [EMAIL PROTECTED] wrote:


The line in my script (#126) that writes data to this field looks like
this:

ie.text_field(:name, Business Income/Extra Expense/Rental
Value_0).set(account[bldgBI])


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

Re: [Wtr-general] How to run all the steps defined in a method even if any of step fails?

2007-04-10 Thread Paul Carvalho

You're repeating yourself, Charley. ;-)  This new assertions.rb covers one
aspect of what Watir User asked but not the other: Its not only related to
assertions .. .  That's why I described a general Ruby construct for
recovering from methods regardless of what Watir version you're using.

Cheers.  Paul C.


On 10/04/07, Charley Baker [EMAIL PROTECTED] wrote:


You can also pull the assertions file and use it with Watir 1.4.1.
https://svn.openqa.org/svn/watir/trunk/watir/watir/assertions.rb  Download
this file, put it in your watir/watir directory and use it the same way I
mentioned in my previous mail.

-Charley

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

Re: [Wtr-general] How to check presence of link by using begin - until method

2007-03-29 Thread Paul Carvalho

Hello Watir user,

I get an error when I try to execute the command ...  Perhaps you
could include a little more code in your email post?

Also, can you please clarify what it is you are trying to do in the web
application (i.e. as a user)?  What triggers the link to appear?



On 29/03/07, watir-user watir-user [EMAIL PROTECTED] wrote:


Hi,

I need to check presence of a link after some process
begin
...
...
end until (link appears)

This is quite simple, but got struck

Thanks in advance,

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

Re: [Wtr-general] hi, Is there a GOTO function for watir

2007-03-28 Thread Paul Carvalho

No.

Read this important article : http://en.wikipedia.org/wiki/Spaghetti_code

Please rethink how you structure your code.  I *highly* recommend taking a
course on Programming Concepts and Design if you haven't done any formal
structured programming/scripting in a *long* time.

GOTO's bad.  Very, very bad.  =P

Good luck!  Cheers.


On 28/03/07, Maloy kanti debnath [EMAIL PROTECTED] wrote:


hi,

IS there any function which is simlar like VB 6.0 GOTO so
that we can say
if condition
goto line 8
else
goto line 20
end


thanks
Maloy

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

Re: [Wtr-general] Testing a development process

2007-03-16 Thread Paul Carvalho

This is a great question and a tough one too.  One of my philosophies during
my career has always been to make myself replaceable so that I can move onto
other more interesting things.  In your situation, it sounds like you've
accomplished that.  You introduced a tool and a desire to move testing back
towards the development staff.  That's a great success, isn't it?

That aside, I work in a small agile development shop and my boss understands
the value provided by having independent software testers on the RD team.
Using a scripting tool to assist in the testing effort is not the same as
automating testing.  I don't believe that you can automate the complexity
involved in real Testing.  (And not in the foreseeable future either.)

So the question I would pose back to you is this: can you articulate to the
CTO what the difference is between testing software and computer assisted
testing (i.e. otherwise called 'test automation')?

Hint: the value you provide is not in the scripting.  If your CTO can't
understand that, then you might be better off looking for a new contract
elsewhere anyway.

Best wishes!  Cheers.  Paul C.


On 16/03/07, Tunde Jinadu [EMAIL PROTECTED] wrote:



Help,

I've introduced Watir to a small software house i'm contracted with and
now they love it so much, they want to get rid of me and include watir
scripts in their build process. The CTO's comments are Thank you for
introducing us to Watir, WatirN, Goodbye. How can I convince them that they
need a tester to write Watir, Watin scripts to ensure an independant eye and
approach to testing.

What are your suggestions

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

Re: [Wtr-general] Click on button which isn't a button

2007-03-16 Thread Paul Carvalho

Hi Adam, this is the situation we have with our navigation bar for one of
our web apps.  Using Watir 1.4.1 I couldn't use the 'text' attribute for
SPAN tags and none of the Spans had unique ID's.  What I ended up doing was
creating two methods to help us navigate the system.

The first one is called 'populate_navigation_bar' and the second is
navigate_bar().  In the first method, I iterate through all the Div and
Span tags with the desired information and put them into a Hash array.  The
'values' are the index numbers.

Then when I want to navigate through the system, I call the navigate_bar()
method and pass it the name I want and the method clicks the corresponding
element using the index number.  This gives me a certain amount of
flexibility in my tests because I can now select random elements really
easily for each test run, navigate to the 'top' of the list regardless of
whatever it's called, and other cool things like that.

In Watir 1.5.x, I can now use the 'text' attribute for Spans, but I decided
to keep navigating the system the same way because I have greater control
this way.

That's how I deal with the problem anyway.  Maybe this might work for you?
Good luck!

Cheers.  Paul C.


On 16/03/07, Adam Reed wrote:


 This brings up an interesting issue that came up yesterday.  We have a
new front-end designer on staff who was creating some mockups for a new
project.  I was getting familiar with his code and using watir to navigate
around, and noticed that of the ~90 divs on the page, only 5-6 have unique
(or any) id tags.  These unnamed divs make up the primary navigation system
for the site.  There are no images, buttons or tables on the page.

So of course, not thinking much into it - I ask if it would be possible
for him add unique id tags to the major navigational elements (50% of the
divs are not important to anything other than design).  He replied, saying
that adding unique ids to all elements would wreak havoc with style sheets,
since all of these unnamed divs share the same style information.  Also, for
Search Engine Optimization (SEO), he needs to keep as much unnecessary text
off the page as possible (although this point is debatable).

In this case, where do we go from here?  I completely understand his
point, but at the same time I would be prevented from automating the
majority of the tests on the new site.  Of course we don't rely 100% on
automation (probably less than 50%), but 100% manual testing requires quite
more time, and produces many fewer test results.

I'd be interested to hear solutions, or just comments on the issue - I
know it has to be fairly common.

-- Adam

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

Re: [Wtr-general] Click on button which isn't a button

2007-03-16 Thread Paul Carvalho

Heh.  You didn't miss the point.  That's why populate_navigation_bar is a
method! ;-)

Cheers!  Paul C.


On 16/03/07, Adam Reed [EMAIL PROTECTED] wrote:


 Thanks for the help Paul.  I did have one question about this method,
however:

As far as putting indexes and the name you want in the Hash array, does
this assume that the indexes of certain elements are constant through the
website?  The reason that I didn't use index navigation inititally was
because as each div is clicked and activated, the div indexes around the
page appear to change.  While at first the Home div is #7, after being
clicked it becomes #9.  Would this throw a wrench in the gears of your
script?

There's a very good chance I've just missed the point, but that's how I
understand it so far.

Thanks again,
Adam

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

Re: [Wtr-general] How to read all text fields of a page and store it into an array

2007-03-15 Thread Paul Carvalho

What have you tried and where have you looked for the answers?


On 15/03/07, sikander [EMAIL PROTECTED] wrote:


 Hi,

I have an array say arrayTextfield1 = [textfield1, textfield2, textfield3,
textfield4, textfield5, textfield6]

In a page i have following fields

textfield1
textfield2
dropdown1
button1
textfield5
dropdown2
dropdown3
button3

Just i will create a array called arrayTextfield2=Array.new. Now I want to
push all the text fields with their names into this array. And finally i
want to compare these two arrays saying that arrayTextfield2 contains the
textfields of arrayTextfield1

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

[Wtr-general] OT: Regular Expression help

2007-03-15 Thread Paul Carvalho

Hi there.  After several hours of looking at this problem, I've decided to
ask for some help.

Here's the problem:  I have an input text file that has a series of values
stored like this:
one   1   0.1234   0   4
two   3   1.   1   0
...

I want the values in the 4th and 5th quotes on each line.  I originally
thought about dumping each line 'split' into an array and working with the
array, but then I thought it might save me time if I could just figure out
the regular expression to get the right values.

I've read through an online Regular Expression tutorial, reviewed a few
books, and downloaded two apps (PowerGREP and Regexile) to help me try and
figure this out but so far no luck.

Here's the line I started with:
line =~ /^\[^]*\t\[^]*\t\[^]*\t\([^]*)\t\([^]*)\t/

= Expect $1 and $2 to hold the values I want... the (bracketed) regex's

- I tried switching the \t with \s but no luck
- tried adding and removing extra backslashes around the quotes, but nothing
- tried adding and removing all sorts of other characters but still can't
get it to work.

Can anyone help me figure out how to parse these input lines in a quick and
efficient way?  I wanted to avoid having to rely on arrays, but I'm ready to
give up and use them right about now.

Please let me know.  Thanks in advance.  Paul C.

(P.S. the *actual* input file has something like 20 values on each line.  If
I can figure out the pattern above for the simplified input file, I'm sure I
can apply it to the larger real input file.)
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] OT: Regular Expression help

2007-03-15 Thread Paul Carvalho

On 15/03/07, Alan Ark wrote:


 Hi Paul.

Just a few notes.

Here's a regex that I came up with.

I used the ? qualifier to make the regex non-greedy – which probably
would have been the next thing that you ran into.


Hi Alan, thanks for the reply.  Your regex string does work in IRB but still
doesn't produce any results in the regex tools I downloaded.  (stupid
tools.)

As an aside, what's wrong with reading the line, then splitting it into an

array?

I think that would have been much more readable than using the regex soln.

Regards

-Alan


I'm thinking about going with the array solution the more I think about it.
Since the actual input lines have about 20 values each, the regex just gets
longer and uglier and harder to understand.  I thought I would give Regular
Expressions a try since I don't use them very often.  I think this is one of
those times when it is *not* the optimal choice for readability and
maintenance!

Thanks for the feedback.  Cheers.  Paul C.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] How to clear the cache of the browser?

2007-03-08 Thread Paul Carvalho

Hi Bach, just wanted to chime in on your suggestion.

I tried a similar IE 6 browser setup a year or so ago when testing one of
our web apps.  I noticed very strange behaviour that was directly traceable
back to the Cookie settings.  For our secure (https) web app, it was looking
for some cookie information in the Cache rather than in memory for some of
the pages.  When it couldn't find it there, really strange things started
happening in the application.  Turning the cookies back on made the strange
behaviour go away.  After that test, our developers added a check for
Cookies routine to keep us (testers, and users too) from doing it again. ;-)

Just thought I'd throw it out there that sometimes turning off all Cookies
is not a viable solution.

Cheers!  Paul C.


On 08/03/07, Bach Le [EMAIL PROTECTED] wrote:


Swarma,

Actually, I believe keeping the cookies from writing to disk is a better
solution than the one Paul is suggesting (using code to delete it). In IE7
(don't know about 6 but I think it is possible).

In IE7, do the following:

1. Tools - Internet Options
2. Click on the Privacy Tab
3. Click on the Advanced button
4. Check Override automatic cookie handling
5. Under First-Party Cookies, select Block
6. Under Third-Party Cookies, select Block
7. Check Always allow session cookies

This will keep the cookies in memory for as long as the browser is open
and clears them when the browser is closed. Cookies are never written to
disk so the data does not persist across multiple IE processes.

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

Re: [Wtr-general] Excel Interface Class

2007-03-05 Thread Paul Carvalho

By any chance, would anyone be interested in writing a hook into Google
Spreadsheets?  I guess you'd sacrifice speed for portability.

Paul C.


On 05/03/07, Paul Rogers [EMAIL PROTECTED] wrote:


I use Open Office. Having the Excel reader is handy, but it obviously
doesnt
work for me. I started working on some code that would read open office
spreadhseet files. It would be great if you could make it work on both,
with
the same interface, especially as things like firewatir and safari watir
work well on non windows platforms.

The open office format is an xml file in a zip, and its actually quite
easy
to work with.
I can send you my code if you like

Paul

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

Re: [Wtr-general] Selecting an 'accented character' from a list

2007-03-02 Thread Paul Carvalho

Hi John, this may or may not be useful but when I work with accented items
like these, I treat them like a black box.  That is, I don't look into the
box to see how Ruby translates them .. which may or may not be how Ruby
really sees them.  In your select_list, can you refer to that service name
item by index instead of by text?

Not being a real programmer, I don't know if how I do things is the right
way or not, but I make *a lot* of use of arrays.  When I need to navigate
between names with accented characters, I drop all the contents into arrays
and then navigate by id and index numbers instead.  Hashes are really good
to me sometimes.

I spent some time months ago doing the same kinds of code magic translations
that you are proposing below but I gave up in frustration after a few days.
In my case, it looked like what Ruby showed me and what it really saw were
not the same thing, so I found it was best not to look at all.

Again, this might not help you, but it's how I managed to get around a
similar problem.  I don't know what your scripts do.  My scripts just kind
of randomly choose whatever data they need on the fly so no two runs are
ever the same.  I think the only data that I know my scripts reuse are the
user ID and password to log into the system.  Everything else sits in
randomly-created or selected variables and arrays.  I let Ruby work with
whatever data it finds.

I know.  It's weird.  But that's how I test, so I've programmed my scripts
to work the same way I do.  ;-)

Best of luck!  Cheers.  Paul C.


On 02/03/07, John Lolis [EMAIL PROTECTED] wrote:


Looking for a bit of help here.

I have a select list that has the following value 'Nome do serviço'.

When I do select_list(whatever).text i get back 'Nome do servi\347o'

if i look in the source of the html i get 'Nome do servi#231;o'

I also found code to convert 'Nome do serviço' to 'Nome do servi#231;o'
(but thats not what ruby sees)

so...

I need a way to convert 'Nome do serviço' to 'Nome do servi\347o' (i
think...)

# Code to convert from 'Nome do serviço' to 'Nome do servi#231;o'
# stolen from somwhere

def entities( str )
  converted = []
  str.split(//).collect { |c| converted  ( c[0]  127 ? ##{c[0]}; : c
) }
  converted.join('')
end

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

Re: [Wtr-general] Test Data Cleanup/Reset Database in a .bat between tests

2007-02-26 Thread Paul Carvalho

I think you might be interested in the 'setup' and 'teardown' methods.  Read
through the ruby-doc.org page on the Test:Unit module.

On 26/02/07, Jason [EMAIL PROTECTED] wrote:


I have numerous TC methods within a class.  Before I execute the script, I
have a batch file (C:\mybatchfile.bat) I run that basically resets the
database and then performs some inserts for database setup.  The test data
and scripts I am creating are using the same data.



[snip]

So, how can I call this batch file in between each TC, with the batch file

completing before starting TC#2?

TIA,
Jason

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

Re: [Wtr-general] TextField#set and utf-8

2007-02-23 Thread Paul Carvalho

I was able to input extended Ascii characters into text fields but I didn't
do it this way.  I should clarify that they were accented European
characters, not CJK.

I have a Watir script that sets up the base test data in the system. It
reads the inputs from an Excel file into an Array and then I use the array
data to populate the text fields.

I'm just looking at the data now.. it looks fine to me.  I didn't use any
special 'require' lines or KCodes.  I just let Excel worry about holding the
data I wanted and assumed the ruby array would hold and use the data I gave
it.. which it did.

Sorry if this solution doesn't work for you.  It worked for me.  You asked
if anyone had gotten it to work.  Apparently I have by not trying to
directly input the special characters.  Is that a limitation of the 'set'
method?  Dunno.

Good luck!  Cheers.  Paul C.


On 23/02/07, Željko Filipin [EMAIL PROTECTED] wrote:


I want to set text field to željko.

ie.text_field(:index, 1).set(željko)

But, Watir sets it to §eljko, Ĺľeljko or just eljko or some other
string (depending if I try from irb, or file that is saved in different
encodings).

I have saved file as utf-8 and this to the top added

require win32ole
WIN32OLE.codepage = WIN32OLE::CP_UTF8

I have tried
ie.text_field(:index,1).value=(željko)

I have tried adding this to the top of the file.

$KCODE = 'utf8'
require 'jcode'

I am reading threads from this list and searching Internet for utf-8 and
Ruby, but no luck for now. I just wonder if anybody has solved this?

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

Re: [Wtr-general] while not exists does not work in Firewatir?

2007-02-13 Thread Paul Carvalho


Steve wrote:
 while not ($browser.link(:text,Withdraw).exists?)
 sleep 1
 $browser.reload()
 end

1.) Is there a better way for me to do this?


I am not sure why you are getting the text of old screen.



This question reminds me of a similar problem that I encountered a while
back.

One of my early scripts had this problem on one particular page of an
application I was trying to navigate.  When I would click a node in a tree
structure, the corresponding information pane was supposed to update.
However, the ruby scripts moved too fast and the script kept returning a
similar error - i.e. it found the text from the previous page, not the
new/next page that I wanted.

In the end, I got around this by telling the script to not only wait for
what I wanted *to exist* but also to wait until what *used to be there*
*doesn't exist*.  The code looked like this:


sleep 1 until $ie.span(:id, /NodeIdLabel/).exists? and $ie.span(:id,

/NodeIdLabel/).text != '.'

For the major application that I've been using Watir to test, I need to tell
the scripts to specifically wait for all of the frames to finish loading.  I
use the wait function on each frame for that.

This one application was different because it didn't have frames like that.
That is, ie.show_frames returned that there are 0 frames.  The exists?
part of the command above was important too because sometimes the script
would hit the page again when it was in the middle of refreshing and it
would break because there was *nothing* on the page to return.

Steve, if you don't have frames that you can apply the wait method to,
perhaps you can try something similar that worked for me?  That is, tell the
script to wait until what's currently there to go away *and* the link you
want to exist.

Just a thought.  Good luck.

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

Re: [Wtr-general] OT: algorithm help?

2007-02-13 Thread Paul Carvalho

Hi Chris, unfortunately, I don't remember enough math right now to be able
to offer a better solution than what you've already come up with.

The only catch that I can think of is that since you are looking for a
*percentage*, the many in your many.times do loop needs to be a
relatively large number for it to produce the kinds of numbers you want.

That is, many should be = 1000.  If it's less than that, your random
number generator may have too much variability and your methods won't be
called the desired percentages.  (I confirmed this for myself by writing a
small script based on your pseudo code below.)

If many is a smaller number, you may need to come up with another approach
to ensure the desired percentages.  (e.g. I can think of another approach
using array lengths... bit more complex than what you've got now.)

If many is a random or unknown value, talk to a mathematician! ;-)

Let me know how it goes.  I'm interested to hear how this turns out for you.

Cheers.  Paul C.


On 12/02/07, Chris McMahon [EMAIL PROTECTED] wrote:


Say I have 3 methods a, b, c.   Over the course of many iterations, I
want to call each method a certain percentage of the time.   Say I
have a config file like

method percentage
a 30
b 30
c 40

I'm thinking of writing code that will load up integer ranges like
arange = [1..30]
brange = [31..60]
crange = [61..100]

and then do

many.times do |foo|
num= rand(100)
if num in arange
 a
end
if num in brange
b
end
if num in crange
end

end #loop


So two questons:
First, is this is a sane approach?  Is there any more elegant way to
call an arbitrary method a certain percentage of the time for a random
number of iterations?


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

Re: [Wtr-general] 'http://wiki.rubygarden.org/Ruby/page/show/ScriptingExcel', is not working

2007-02-11 Thread Paul Carvalho

Looks like RubyGarden is temporarily down - perhaps a maintenance window.
I've attached a copy of the page that I happened to have saved for just such
an emergency. ;-)

Cheers.  Paul C.


On 12/02/07, vijay [EMAIL PROTECTED] wrote:


Hello people,

The link, 'http://wiki.rubygarden.org/Ruby/page/show/ScriptingExcel', is
not working.  Please, if any of you people, know the updated link, let me
know.

Thanks,
Vijay.

Title: Ruby: ScriptingExcel








  login
  
  
ScriptingExcel

  (Ruby)

  

  
  HomePage
| RecentChanges
| Preferences
| Wikis
| RubyGarden
| Feed-icon-16x16
  
  
  
  
  





Although the Pickaxe book has some examples of scripting Excel, I still had quite a lot of digging to do for some of the scripts I needed. I got some by looking at the M$ docs (poor as they are**), and some by looking at Perl examples. So this page is for collecting examples of code that others might adapt (and add to).

See also: ScriptingOutlook, ScriptingAccess



 You can download the Office XP Excel Object Reference help file as part of an expanded help bundle here [1]. It's large [19MB], but it includes a bunch of VBA help files that I couldn't track down otherwise. The file you need for Excel items is VBAXL10.CHM. It appears to have complete docs on all the Excel objects. -- ChrisMorris



 A great resource for general Excel and programming related questions (well with VBA) are Chip Pearsons [Excel Pages]. I learned a lot from his article [Cell References In A Range] for example. -- BernhardLeicher

First of all:

require 'win32ole'



Opening spreadsheets, accessing workbooks and worksheets

excel = WIN32OLE::new('excel.Application')
workbook = excel.Workbooks.Open('c:\examples\spreadsheet.xls')
worksheet = workbook.Worksheets(1) #get hold of the first worksheet
worksheet.Select  #bring it to the front -need sometimes to run macros, not for working with a worksheet from ruby
excel['Visible'] = true #make visible, set to false to make invisible again. Don't need it to be visible for script to work




reading data from spreadsheet

worksheet.Range('a12')['Value']  #get value of single cell
data = "" #read into 2D array


finding the first empty row (using empty column A)


line = '1'
while worksheet.Range("a#{line}")['Value']
   line.succ!
end #line now holds row number of first empty row


or to read as you go


line = '1'
data = ""
while worksheet.Range("a#{line}")['Value']
   data  worksheet.Range("a#{line}:d#{line}")['Value']
   line.succ!
end




writing data into spreadsheet, example


worksheet.Range('e2')['Value'] = Time.now.strftime '%d/%m/%Y' #single value
worksheet.Range('a5:c5')['Value'] = ['Test', '25', 'result']




loading all Excel constants into a class

class ExcelConst
end

WIN32OLE.const_load(excel, ExcelConst)

Now the constant xlDown is accessible as ExcelConst::XlDown

To find out what constants to use you can use this script.  You run it by passing in a string which is matched against the constant names.

  require 'win32ole'
  
  module ExcelConsts
  end

  excel = WIN32OLE.new("Excel.Application")
  WIN32OLE.const_load(excel, ExcelConsts)
  excel.quit()
  
  puts 'Matches for: ' + ARGV[0]
  ExcelConsts.constants.each {|const|
match = const.match(/#{ARGV[0]}/)
value = eval("ExcelConsts::#{const}")
puts ' '*4 + const + ' = ' + value.to_s unless match.nil?
  }


An example would be looking for the constant to center text.  I ran
 ruby search_excel_consts.rb Center 
and the following results came up:

  XlCenterAcrossSelection = 7
  XlVAlignCenter = -4108
  XlCenter = -4108
  XlLabelPositionCenter = -4108
  XlPhoneticAlignCenter = 2
  XlHAlignCetner = -4108
  XlHAlignCenterAcrossSelection = 7


calling macros

excel.Run('SortByNumber')



Setting background colour

worksheet.Range('a3:f5').Interior['ColorIndex'] = 36 #pale yellow
# Set background color back to uncoloured (rnicz)
worksheet.Range('a3:f5').Interior['ColorIndex'] = -4142 # XlColorIndexNone constant
# or use Excel constant to set background color back to uncoloured
worksheet.Range('a3:f5').Interior['ColorIndex'] = ExcelConst::XlColorIndexNone




Adding Formulae


emptyRow = 15
worksheet.Range("t#{emptyRow}")['Formula'] = "=(Q#{emptyRow}+L#{emptyRow}+I#{emptyRow}+S#{emptyRow})"




saving changes


workbook.Close(1)

# or
workbook.SaveAs 'myfile.xls'
# default path is the system defined My Documents folder




ending session

excel.Quit

If you're experimenting from within irb and are having problems with processes hanging around after you've called excel.Quit - try deleting the reference to excel and invoking the garbage collector.

excel.Quit
excel = nil
GC.start



Hopefully this is of some use. Please add anything else you have discovered.



Some further stuff that I learned so far...
It 

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 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() #8212;#8250; IE object constructor: `initialize()`
#8212;#8250; `initialize()` calls `create_browser_window()` #8212;#8250;
`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

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] while not exists does not work in Firewatir?

2007-02-06 Thread Paul Carvalho

I try to avoid icky double negatives.  Does the following line work for you
instead?

sleep 0.5 until $browser.link(:text, Withdraw).exists?



On 05/02/07, steven [EMAIL PROTECTED] wrote:


The following code only seems to work if $browser = ie.new, and not
firefox.new (i.e. with Firewatir).  Am I missing something or is this a
known issue?

while not ($browser.link(:text,Withdraw).exists?)
   sleep 0.5
end

To clarify, when I mean does not work, I mean, it never catches the link
as existing, even though it is there.  It just stays in the sleep command
over and over.

Thanks,
Steve

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

Re: [Wtr-general] Installation Problem

2007-02-05 Thread Paul Carvalho

Install Watir 1.4.1 to a folder with no spaces in it.  e.g. C:\Watir

It should work.


On 02/02/07, RobG [EMAIL PROTECTED] wrote:



I hope this is an acceptable topic for this list...

I just installed Ruby 1.8.5 on my system, and then, with much effort,
managed to get the watir-1.4.1.exe installed (it has a major install bug
that I was able to circumvent).

So after all that, I open a command prompt into the installation
location, and run all_tests.rb as instructed, and I get the errors below:


C:\Program Files\Watir\unittestsall_tests.rb
C:/Program Files/Watir/unittests/../unittests/setup.rb:4:in `require':
no such f
ile to load -- watir (LoadError)
 from C:/Program Files/Watir/unittests/../unittests/setup.rb:4
 from C:/Program Files/Watir/unittests/all_tests.rb:4:in 'require'
 from C:/Program Files/Watir/unittests/all_tests.rb:4



It looks like it might be a simple pathing issue, but I'm not sure.  I
do have the path setup so that I can run regular ruby, but I haven't
tried to add anything for watir yet; I thought I would ask here first.

I don't remember having this problem about eight months ago when I first
tried Watir, but that was on another computer.

Any help would be appreciated.  Thanks!

Rob


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

Re: [Wtr-general] Everyday Scripting with Ruby (the book)

2007-02-05 Thread Paul Carvalho

On 01/02/07, Richard Conroy wrote:


I am curious what everyone thinks of this (new) book.

It starts off well, with the first example tutorial being
how to test if an uninstaller worked. No hello world,
silly arithmetic examples etc.

Well it is ordered, I will know myself soon.



I reviewed a late draft of the book late last summer 2006.  I think that the
book is a great companion to the Programming Ruby 2nd edition that has been
(and still is!) an invaluable reference for me.  The thing is that I'm not a
programmer by trade and my Ruby/Watir scripts were all horribly pieced
together like some kind of franken-code based on example snippets and email
posts that I came across.

After reading Brian's book, I was able to construct well-designed Ruby
scripts, refactor all of my earlier Watir scripts, and can now understand
more lengthy and complex pieces of Ruby code.  I also really like how Brian
didn't start with the typical hello world example and instead jumped right
into scripts that can solve real-world problems.  A test the water with
both feet kind of approach. =)

I certainly learned many useful things from Everyday Scripting with Ruby
and am looking forward to putting a hardcopy on my shelf next to my
Programming Ruby copy.  There's more in there that I need to digest but it
will take time (for me) since I only script in cycles, and I test more than
I script.

The book covers a lot and has many different layers in it that I think would
be useful to both beginners and intermediate scripters, and not just
testers.  Most importantly (for me) is that it is a fairly easy-to-read
book.  Most of the programming/scripting books that I have read or skimmed
through really seem to be speaking a language I almost, but don't quite
always, understand -- and that includes the Programming Ruby book.  I
found that Brian's book uses clear, simple language and builds upon terms
that he has already introduced and explained earlier in the book.  That made
it easier for me to stick with it and work through the more complex
examples.

I'd recommend it.

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

Re: [Wtr-general] undefined method `[]' for nil:NilClass (NoMethodError) error at the end of array???

2007-01-24 Thread Paul Carvalho

On 23/01/07, Bret Pettichord wrote:


This is largely because Watir is stupid in this area. We made a bad
design choice with Watir 1.0. We'd now like to make Watir consistent and
start with 0 everywhere (like everything else in Ruby) but this would
raise compatibility issues. We welcome your thoughts in this area.



I think being consistent everywhere would be a good thing.  If that means
being consistent with Ruby and starting at 0, then so be it.

Personally, I think the person who first coded programming/scripting
languages to start counting at 0 should have had his/her head examined and
then been committed to an insane asylum.  I've learnt many programming
languages over the years and even once sat and painfully read through a
series of programming language manuals as long as a desk shelf back almost
20 years ago.  I still recall how that language was hailed as a
Fourth-Generation Language that was supposed to make programming easier
because the syntax and vocabulary (commands, methods, etc) were closer to
more natural language.  It seemed ironic that the easier the language was
supposed to be, the more manuals were required to teach you how to program
in it.

The point here is that it is natural for human beings to start counting at
1.  I have never in my entire life ever heard anyone start counting at 0.
*That* is stupid.

So, Paul, how many children do you have?  Well, my first boy would be 0,
and my second son would be 1, so I guess I have 1 child.  Even the Cat in
the Hat's best friends are Thing 1 and Thing 2.  I would have like to
have heard Dr. Seuss' thoughts on the topic of counting.

If machines can't be made to speak *our* language, then they're not very
useful.  Forcing people to think and code in that way is an impediment to
clear, human thought IMHO.

In the absence of something good, I'll take something consistent.  The
enemy you know and all that, right?  If you want to attract
non-programmers to the use of the tool, then you will have to appeal to them
in a friendly, non-programming way.  (That would include not forcing them to
rethink how to count because that's not a friendly thing to do.)

I recall Gracie Hopper once saying that if you hear the phrase that's the
way it's always been done then you know it's time to change it.

Well, you asked for my thoughts. ;-)  Thanks for asking.  Let me just put
this soapbox away for now.. ;-)

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

Re: [Wtr-general] undefined method `[]' for nil:NilClass (NoMethodError) error at the end of array???

2007-01-23 Thread Paul Carvalho

This is one of those times when I'll never understand why some things in
programming start counting at 1 and some things start counting at 0.

I, too, have several similar loops in some of my scripts, but I opted for
the more readable format of saying:

t.length.times { |x|
   puts t[x][0]
}

I just can't be bothered with loops like 1.upto(t.length) {|x| puts x}
which, technically, counts from the first item to the last item, but
really x starts counting at 0 and goes to (length - 1).  This might be
convenient if you are working with arrays but not a whole lot else.

Paul C.



On 23/01/07, Chris McMahon [EMAIL PROTECTED] wrote:


On 1/22/07, mi [EMAIL PROTECTED] wrote:
 t = [[a, b], [aa, bb]]

 0.upto (t.length) { |x|
 puts t[x][0]
 }

 For some reason i'm getting the following error at the end of the loop,
 any idea WHY???

0.upto (t.length-1) { |x|
 puts t[x][0]
}

should do it, but I think you figured that out.

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

Re: [Wtr-general] Ruby equivalent of 'Continue' in C

2007-01-19 Thread Paul Carvalho

For those of us who don't know how to program in C, can you please explain
what Continue does?  It's not entirely clear to me what you are trying to
do.


On 19/01/07, sarita [EMAIL PROTECTED] wrote:


I want to execute a test on a table where links are to be clicked based
upon its status. Only when status not 'Complete', it's to be clicked 
further actions to be performed. Otherwise those steps to be skipped. So,
thinking of Ruby equivalent of 'Continue' in C. Please help.

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

Re: [Wtr-general] Watir with Ajax

2007-01-19 Thread Paul Carvalho

Are these links and fields within frames?  Do you know if the frame has
completely finished loading after the click and before the text_field is
set?  What version of Watir are you using?


On 19/01/07, Naga Harish Kanegolla [EMAIL PROTECTED] wrote:


HI,
  But its not working for me. Basically its working for all the
text_fields. But not working for this, I hope its becoz the form is
rendering dynamically thru ajax call. This is the error..
Error::
c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1939:in `assert_exists': Unable to
locate object, using name and contract_my_document[title]
(Watir::Exception::UnknownObjectException)
from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:3393:in `set'

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

[Wtr-general] OT - Bug in Ruby with adding strings?

2007-01-19 Thread Paul Carvalho

I just found what looks like a bug in Ruby.  Here's a simple script that
will expose this bug:

irb(main):001:0 x = 1
= 1
irb(main):002:0 puts 'foo' + x.to_s +'bar'
SyntaxError: compile error
(irb):2: syntax error
puts 'foo' + x.to_s +'bar'
^
   from (irb):2


I finally figured out that it was the Plus sign *right next* to the bar,
*after* the to_s method that Ruby dislikes.  If I insert a space, I get
the correct output.  If I take out both spaces, I get the correct output.
It's only if there's a space after the to_s and none between the Plus sign
and string-in-quotes that it blows up.

That is:

puts 'foo' + x.to_s + 'bar' # this works
puts 'foo' + x.to_s +'bar'  # doesn't work
puts 'foo' + x.to_s+ 'bar'  # this works
puts 'foo' + x.to_s+'bar'   # this works



Anyone know why this might be?  Is there a proper place where I might pass
this information on? (I'm not on any other Ruby groups right now.)
I haven't played with it anymore, so I wonder if this bug exists with other
methods.

I'll try to remember to be consistent with my spaces moving forward.
Thought some of you might be interested.

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

Re: [Wtr-general] What does IE.down_load_time really measure?

2007-01-15 Thread Paul Carvalho

On 13/01/07, Bret Pettichord wrote:



Would it be possible for you to provide code and output that are synced up
with each other?

Bret



Sure thing.  Rather than include everything, here are some relevant bits:

Aside: filename written to from the setup method:
 filename1 = 'site_map_output'+ f_count +'.csv'
 $f =  File.new(filename1,  w)
 $f.puts #{header_info}

def walk_Main_Menu

 $f.puts '3. Main Pages:,Page Size (bytes),Page Load Time 1 (s),Page
Load Time 2 (s)'
 # set the page_name array..

 # Log in, update password, and go to the Home page
 secondary_page_timer = Time.now
 $ie.button(:name, /UpdateSettingsButton/).click
 record_measurement( page_name[0], secondary_page_timer )

 # go on to the next page...

 def record_measurement( page_title, secondary_page_start_time )
 $f.puts page_title  + ',' + $ie.html.length.to_s + ',' +
$ie.down_load_time.to_s + ',' + (Time.now - secondary_page_start_time).to_s
 end


= And the output file from a script run contains numbers like the
following:

3. Main Pages:,Page Size (bytes),Page Load Time (s),2 Page Load Time
(s)
a) Home,15210,0.015,1.075
...
k) Personal Settings,33639,0.872,1.06
...
m) Contact Support,15106,0.373,0.514



(BTW, I'm still removing the global variables as I come across them, so
there are still a handful left.  The script may not be the prettiest from a
programming perspective, but it's a small site and the script works, so it's
good enough for me for now.)

I think the Home page might be cached in the browser and so the download
time is negligible.  The server response time navigating between the pages
still takes about a second though.  So I'm wondering if IE is making a
distinction between how long it takes to get the page versus how long it
takes to finish what it was doing with the last page visited.

Dunno.  I'll try changing up the order in which the pages are loaded and
clearing the browser cache to see if it makes a difference, but the ~300 ms
difference between the timers seems to be consistent.  (There are other
pages with a bigger time difference than that observed with the Home page!)

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

Re: [Wtr-general] What does IE.down_load_time really measure?

2007-01-15 Thread Paul Carvalho

Hey Bret, I have another question.

I'm almost finished updating another script that walks through the pages of
another web app and I'm noticing that the average difference between the
timers is ~ 2.0 seconds!

This second app is mostly frames though.  So when I issue the following
command:

  ie.down_load_time

Does it report the download time for the whole page, i.e. including all of
the sub-frames, or does it only return the download wait time for the outer
IE frame?

Since I've written a separate method ('wait_for_frames') that waits for all
of the frames to finish loading before proceeding to the next LOC, it got me
wondering that perhaps your code example below doesn't include the wait time
(and therefore download time) for all of the sub-frames.

Do you know if this would be fixed in 1.5.x?

Please let me know.  Thanks.


On 10/01/07, Bret Pettichord wrote:


The down_load_time is the amount of time that watir waits in the wait
method that is automatically called after the click. It should be
roughly the same as the wait_time defined below:

ie. button(:name, /UpdateSettingsButton/).click!
then = Time.now
ie.wait
wait_time = Time.now - then


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

Re: [Wtr-general] problem in accessing elements of web page

2007-01-12 Thread Paul Carvalho

Instead of ie.wait, I wrote and use the following method call:

 def wait_for_frames
 $ie.wait
 if $ie.document.frames.length  0
 $ie.document.frames.length.times {|x| $ie.frame(:index, x+1 ).wait
}
 end
 end

I imagine others may use something similar.  You should be able to modify it
to suit your needs.

Cheers.  Paul C.


On 12/01/07, VIKASH KUMAR [EMAIL PROTECTED] wrote:


I am running running a test case in windows platform.

Some of the time page can't get downloaded fully, due to slow speed, then
my code breaks, by giving message object not found - something like this.

I tried *ie.wait,* but it is also not working for me as there are lots of
frames in the page, page can get download but the elements inside the frame
used to take time for downloading.

If I use sleep 5, or sleep 10 then it works for me, but I want to avoid
using sleep in my code, what should be the better approach of doing this.

Please help me out.

Thanks in advance

Vikash

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

Re: [Wtr-general] Iterating through all options of a List Box which is again dynamic

2007-01-12 Thread Paul Carvalho

You can use something similar to the following to get you started:

variable = ie.select_list( :id, /ListName/).getAllContents



On 12/01/07, sarita [EMAIL PROTECTED] wrote:


I want to run a test, which'll create one sample record for each option in
the List Box. Again the options in List Box is dynamic i.e, can be changed
through another module. How to iterate the test till the last option in the
listbox.

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

[Wtr-general] Need Regular Expression help with a URL string

2007-01-11 Thread Paul Carvalho

Okay, I give up.  I've worked on this for over an hour and I need more
experienced help.  (Web searches and book references haven't helped either.)

I have a URL in a string and I'd like to replace part of it but first I need
to find the part that I care about.  Here's an example of the string:

web_url = 'http://foo/bar.html'

Now, what I am trying to do is find the *last* forward slash (/) in that
string so that I can then replace everything after it.  I am having
difficulty finding that last slash though.

I am trying to use the   str[ regexp, int ]  function, but I can't seem
figure it out.

Can anyone help me with this regexp?  Once I get it I'll figure out what's
the best function for what I need to do.  Thanks.

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

Re: [Wtr-general] Need Regular Expression help with a URL string

2007-01-11 Thread Paul Carvalho

Thanks Alan!  That works better than what I was trying to do.  Now I can
create the new URL with a line like:

new_url = ie.url[/(.*)\//] + new_page.html

Sweet!  I was trying expressions like =~ /\\// but wasn't having any luck.

Cheers!  Paul C.


On 11/01/07, Alan Ark [EMAIL PROTECTED] wrote:


 Hi Paul.

The following should work:

irb(main):001:0 web_url = 'http://foo/bar.html'

= http://foo/bar.html;

irb(main):002:0 web_url=~/(.*)\//

= 0

irb(main):003:0 p $1

http://foo;

nil

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

Re: [Wtr-general] OT: Need help Trapping Errors in Ruby

2007-01-11 Thread Paul Carvalho

Hi Nathan, thanks for the follow-up.  I do have it working, as per my last
message in this thread, but I'll offer some additional info here since you
asked.

The $something_went_wrong variable is a legacy variable from when I first
wrote these scripts using Watir and I was trying to tell the script that a
particular 'test' method did not successfully complete.  It isn't really
used in the write_status() method.  That variable is used by a
complete_walkabout() method that runs at the end of the script -- which
cleans up the environment (e.g. closes files) and makes a decision based on
the successful completion of the test (i.e. whether or not something went
wrong).

I'm in the process of refactoring the logic and how the code works, and am
taking it one step at a time.  (I may even end up getting rid of that
variable.)  Basically what the script does is this:  Open IE, walk the web
app's site map, capture some performance metrics and close the browser.

What I *want* the script to do is recover from any page or link that it
fails to connect to.  The script *used* to do this in a very neat way, but
that way wasn't transferable to the new Ruby script structure that I'm
using.

So how do you get the script to recover from an error and make it through
right to the very end? (I asked myself)

I put all the walk the site map pages and capture metrics code into
individual methods and I needed to find a way to capture any exceptions
raised.  I'm not doing any explicit [test] assertions in these scripts, but
the effect is the same.  i.e. if it fails to connect to a page, the script
fails on the next line and it stops cold.

So I tried to wrap it in a rescue block like this:

begin
  call_page_walking_method()
rescue = e
 #do something
end
#keep going


However, as soon as I realised that I needed to do this for *every* page set
I was going to call, I put that (above) code into a method on its own.

The problem is that the above rescue block *doesn't* work.  Ruby didn't get
what I was trying to do.  If the called method failed then the script just
stopped, it didn't return and get rescued like I thought it would.

That's when I discovered that you can put the rescue block *within* the body
of a method.  So I moved it to the method that does the actual walking, and
now it recovers nicely.  Voila!

So I learned one way how a regular Ruby method is different from the
Test::Unit::TestCase class' 'test' method.  The TestCase class will still
proceed to a 'teardown' method if any individual test method terminates
unexpectedly, but a regular Ruby method just stops where it failed.

Now I know how to get my non-TestCase (Ruby/Watir) scripts to recover
gracefully from exceptions.  Cool.

Does that help clarify things?  If not, mail me off-list and we'll chat.

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

Re: [Wtr-general] What does IE.down_load_time really measure?

2007-01-11 Thread Paul Carvalho

Okay, I didn't want to reply right away without trying a few things first.
My results seem to be consistent in that my second counter is always larger
than the default down_load_time value.

On 10/01/07, Bret Pettichord wrote:


The down_load_time is the amount of time that watir waits in the wait
method that is automatically called after the click. It should be
roughly the same as the wait_time defined below:

ie. button(:name, /UpdateSettingsButton/).click!
then = Time.now
ie.wait
wait_time = Time.now - then



I like this code but click! doesn't work in 1.4.1 so I'll try it later on
one of my 1.5.x VMWare sessions.


I'm confused by your example because your output does not match your code.


Which part is confusing?  The script actually outputs in columns of data to
a CSV file.  I just picked a row and listed the results here in a more email
friendly fashion.

If you're wondering why the results don't match, then I'm confused too!

The second RT value is always larger than the IE.down_load_time value by a
difference of 0.12 to 1.5 seconds.  The average seems to be a difference of
~ 350 ms, which is noticeable.


I've updated the rdoc for down_load_time to read:


# The time, in seconds, it took for the new page to load after
executing the
# the last command

Is this clearer?



I'm not sure.  It sounds a bit better than the current description of: use
this to get the time for the last page download.

I like the definition and code example that you gave at the top of your
reply.  That's the clearest I think.  All the other Public methods in the
Watir API reference have nice popup windows with code in it, so your
description and code example above follows the pattern nicely.

...There's just the matter of trying to figure out why there's a difference
in my Response Time values.  I'll keep collecting both for now so that I can
continue developing my scripts.  Maybe inspiration will come to me as I
collect more data and update the scripts further.

Currently, it looks to me like RT = (ie.down_load_time) + (additional IE
render time or other unspecified delay)

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

Re: [Wtr-general] Error with file_field in a modal window (using 1.8.2 / 1.5.1.1127 )

2007-01-10 Thread Paul Carvalho

And you do this how...?  Perhaps you should include a link, reference or
example of how to do this in your response.


On 10/01/07, Angrez Singh [EMAIL PROTECTED] wrote:


Hi John,

You can manually install AutoIt dll using regsvr32 command.

Regards,
Angrez


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

[Wtr-general] OT: Need help Trapping Errors in Ruby

2007-01-10 Thread Paul Carvalho

Hi there, I've got more of a Ruby question than a Watir one, so I hope you
don't mind if I post it here first.

I am in the process of rewriting my first Ruby/Watir scripts from a year ago
- a site-map walkthrough script to collect some simple Performance metrics.
When I first wrote the script, I used the Test/Unit (Class/Test) structure
because that was the only way I knew how to structure scripts at that time.
(i.e. used the Watir examples as a guide.)

A year later, I now know how to structure my scripts in a more regular Ruby
script fashion so I updated my walkthrough script.  I used a neat trick in
my old script to recover from a script error (e.g. assertion failure) and
continue on but I seem to be having some problems doing the same thing with
the Ruby script format.  I was wondering if someone can offer any advice to
help me figure this out.

Here's what I've got so far:

## Main script snippet:
 ...
 # open the IE browser
 $ie = IE.new

 # A) Walk the Public Pages.  = Need to Trap this so the
something_went_wrong variable works correctly
 page_set_to_check( walk_Public_Pages )



# Here's the page_set_to_check() method:

module site_walkabout_methods

 def page_set_to_check( page_set )
 begin
 page_set
 rescue = e
 $something_went_wrong = 'Yes'
 end
 write_status
 end

end


So, the walk_Public_Pages routine gets called, but if there's an assertion
failure in it (e.g. because of an incorrect link name), the rescue = e
part of page_set_to_check() doesn't run like I would expect it to.  In fact,
the whole script terminates at this point!

Please let me know if you have any helpful suggestions to get the script to
auto-recover and continue.

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

Re: [Wtr-general] OT: Need help Trapping Errors in Ruby

2007-01-10 Thread Paul Carvalho

page_set is just a local variable used to call the method name that I want
to execute.

I'm basically calling a method (e.g. 'walk_Public_Pages') from within a
method (page_set_to_check) that is supposed to trap the errors/exceptions.

However, if there's an error in the 'walk_Public_Pages' method, it not only
escapes out of the page_set_to_check() method, but also out of the whole
script!

I'm wondering if changing the main module to a class will have a
different effect?  Just a shot in the dark.  I'm chasing another goose at
the moment, so I'll try that shortly.

P.C.

On 10/01/07, John Lolis [EMAIL PROTECTED] wrote:


I'm a touch confused by this, what is page_set?

My first reaction is to say that somewhere deeper down in your code an
exception is begin thrown and is silently beginning handled thus said
function returns even though things didn't work.

The only reason I'm guessing this is because of the way you handle this
exception.

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

[Wtr-general] What does IE.down_load_time really measure?

2007-01-10 Thread Paul Carvalho

I've got a script that walks through a simple web application and retrieves
the page size and page download times.  (By simple web app I mean no
frames and only about a dozen pages - mostly reports and a Personal Settings
page.)  The script outputs these values to an output CSV file so that I can
then chart them in Excel.

I watched the script run and complete just now and noticed something
interesting.  I watched the Home page take a second or so to come up but
when I checked the output file, it recorded that it took 0.015 seconds
according to ie.down_load_time.

That didn't seem right to me, so I added a second time check to the script.
Like this:

# Begin code snippet:
 ...
 secondary_page_timer = Time.now
 ie.button(:name, /UpdateSettingsButton/).click

 $f.puts page_title  + ',' + ie.html.length.to_s + ',' +
ie.down_load_time.to_s + ',' + (Time.now - secondary_page_timer).to_s
 ...
# End snippet

Now when I rerun the script and check the output file, I see the following:

Page Load Time 1 (s) = 0.015
Page Load Time 2 (s) = 1.075


That's a big difference!  I should mention that this is Watir 1.4.1.  I just
happened to be using this machine right now.  I haven't tried it with any
1.5.x gem yet.

Any thoughts or suggestions?  The Watir API Reference doesn't give any
insights into how the down_load_time attribute works.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] OT: Need help Trapping Errors in Ruby

2007-01-10 Thread Paul Carvalho

Got the answer I need from the Programming Ruby 2nd Edition book and thought
I would share it here.


From the Handling Exceptions section (p. 361), I got that I should add the

rescue block to the end of my site-walking methods, and not the calling
method (i.e. page_set_to_check()).  Basically I was using the rescue block
in a way that Ruby didn't pay attention to.

So I made the following changes to my script:
(1) delete the page_set_to_check() method
(2) added the following rescue block to the end of each page set
(site-walking) method:

module site_walkabout_methods
 ...
 def walk_Public_Pages
 # launch ie
 # goto some page
 # get page size and download time
 # click to another page.  yadda, yadda.
 # ...
 rescue = e
 $something_went_wrong = 'Yes'
 puts e
 ensure
 write_status
 end

end


So the methods themselves are self-correcting and I don't need to try and
capture exceptions with some umbrella method.  Cool.

I'm happy.  Moving on..

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

Re: [Wtr-general] What does IE.down_load_time really measure?

2007-01-10 Thread Paul Carvalho

Hmm, okay, so it looks like there are two interesting sub-measures then.

From a user's perspective, a web page's response time would equal

down_load_time + render time.

How much faith should we put in the IE.down_load_time attribute if it
doesn't include the render time?  I mean, I *watched* the Home page take ~ 1
second to load in the IE browser, so I really don't believe that it took
0.015 seconds to download to the user.

I think I'm going to keep the extra column in my output file for now and
plot both lines on the charts for comparison.

Thanks for checking this, Chris.  (I've tried sifting through the
watir.rbfile but it's still mostly Greek to me... and I'm not Greek.
;))

Cheers.  Paul.


On 10/01/07, Chris McMahon [EMAIL PROTECTED] wrote:



@down_load_time = Time.now - start_load_time
in def wait
line 1519/1476 in watir.rb in 1.5.1127.
:)


difference is probably render time

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

Re: [Wtr-general] Menu links have duplicate attributes

2007-01-08 Thread Paul Carvalho

I also have duplicate menu names in one of our apps.  I just use the link's
index number instead.  It's not as nice or convenient as using the text, but
I don't mind hard-coding a link index every now and then if it means I can
get on with the test and move onto the next thing.


On 08/01/07, Garry West [EMAIL PROTECTED] wrote:


 I am currently having a problem clicking on a menu item.  This menu item
has the same attributes as another menu item, but they both do different
things.  I was using ie.frame(left).link(:id, 21).click (example)
however because the link id's change depending on the user access rights I
found it time consuming and difficult to manage.

I am now using ie.frame(left).link(:title, Edit News).click
(example).  This has now caused a problem because we have two links, both of
them with the same title, but within different directory folders in the menu
tree.

Does anybody know of a solution to this problem?



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

Re: [Wtr-general] Does Watir support a .Net webbased application?

2006-12-12 Thread Paul Carvalho

I have been using Watir to test our .Net web app for almost a year now.  Did
you check to see if there were any frames in your window?


On 12/12/06, Devesh [EMAIL PROTECTED] wrote:


Can Watir be used for testing a .Net based web application ?
On running showAllObjects() function on an .net based web application, no
objects are displayed. Is there any method by which i can automate the page.

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

Re: [Wtr-general] how to access an element whose html tag is A

2006-12-12 Thread Paul Carvalho

Unless I'm mistaken, A HREF.. Click Here /A is a link.  Did you try the
ie.link method?



On 11/12/06, vijay [EMAIL PROTECTED] wrote:


Hello people,

I do not know how to access an element whose html tag is A.  There is a
link, named 'Step 1. Details'.  According to its View Source, it is present
in the following hierachy:

frame - form - div - table and then that element but its html shows as
A class = tab_enabled href = javascript:formSubmit('summary');).

I want to know whether this element is enabled or disabled and want to
click it, if enabled.

Similarly, there are six other elements, 'Step 2. Details', 'Step 3.
Contacts' etc.  These elements will be disabled at the start.  I want to
confirm that.  How do I do these two things?

I tried a command, if 
ie.frame(Detail).form(:name,header).div(:id,header).table(:id,cIDFTabstripTable).element(:text,/Contacts/).enabled?
  ==
true then ,  but Watir says undefined method `element' for
#Watir::Table:0x2ea6058

Thanks, in Advance.
Vijay


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

Re: [Wtr-general] Identifying a tab to click on

2006-12-03 Thread Paul Carvalho

Maybe you're being too specific?

Did you try just: $ie.span(:index, 1).click

Or, based on the id tag, does this work: $ie.span(:id, 'firstTab').click


On 03/12/06, Neil Daniell [EMAIL PROTECTED] wrote:


 I am trying to use Watir to click on secondTab but cannot seem to get the 
following to work:
$ie = IE.new

$ie.div(:index, 1).table(:index,1)[1][2].span(:index, 1).click
Can someone indicate to me how I can fix this?
Is it possible to select an element via the class?

Page source:(jsp)

div class=TabGroup
table width=100% cellpadding=0 cellspacing=0
tr
td nowrap=true width=99
span id=firstTab class=TabSelected 
style=background-image:url(images/tabs/firstTab.gif)
  onclick=if (PageUI.isLoaded()) selectTab(0);
  onfocus=this.click();
  title=First Tabpre 
style=display:none//span
/td
td nowrap=true width=99
%-- Show the Second Tab --%
span id=secondTab class=Tab 
style=background-image:url(images/tabs/secondTab.gif)
  onclick=if (PageUI.isLoaded()) selectTab(1);
  onfocus=this.click();
  title=Second Tabpre 
style=display:none//span  
/td
/tr
tr
td colspan=3 id=TabGroupLine class=TabGroupLine 
style=background: #BDE8FF;/
/tr
/table
/div


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

Re: [Wtr-general] WIN32OLERuntimeError - I get this error after two hours - see details

2006-11-10 Thread Paul Carvalho
Hello Nathan, thanks for all the details you included in your initial post. While I don't think I can add anything more to the programming/troubleshooting side of things than have already been offered, I haven't seen anyone yet ask what else is going on in the system.
Do you have any other programs or services running in the background? (In particular any monitoring programs in the System Tray?) Have you tried collecting system performance metrics while you run your test? For example, using the Windows Perfmon tool, set up a new Counter Log to trace the CPU and Memory usage of the system and the iexplore process. Make sure to create a Text File (Comma delimited) Log file type so that you can bring the results into Excel and examine them after the test failure. Sysinternals also makes some nice tools that you can use for monitoring your system, including Process Explorer, Filemon, etc.
If you can't solve the mystery with the information you have, look for more clues and information.All the best!Cheers. Paul C.On 09/11/06, 
Nathan [EMAIL PROTECTED] wrote:
I am using Watir 1.4 (latest) and Ruby 1.8.5-21 I believe on Windows (of course) with Internet Explorer 6.PLEASE, please help me if you have a solution.I have thought to maybe put a begin...rescue...end block around some of my code to try and keep this from happening, but I'm not sure that would do any good.Oh also, I know pretty much that something WIERD is going on because my browser window is always closed at this point - when the error occurs, which is obviously the reason for the RPC Server problem.But WHY is it closing? 

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

Re: [Wtr-general] OT: Programming/Ruby Logic question

2006-10-30 Thread Paul Carvalho
I like your simplification, thanks.What I was originally trying to do was use a CASE structure, but I couldn't figure out how to use multiple comparisons. That is, I tried something like this:case array[ position ]
 when 'foo' then start_col = 1 when 'green eggs' then start_col = 10 when 'ham' then start_col = 20 when 'bar', first_seen then start_col = 30; first_seen = false when 'bar', ! first_seen then start_col = 40
endBut this doesn't work. Rereading the Programming Ruby 2nd edition several times, I eventually got it that the (multiple) comparisons are only applied to the original array[ position ] object at the top. Ah.
So I had to turn it into a series of if checks. Not as pretty to look at as the above might be (if it actually worked), but I'm happy that I just got it working. Not being a programmer by trade, I like to try new structures every now and then to see if I can simplify what I'm trying to do. Practice makes perfect, eh?
Cheers. Paul C.On 29/10/06, Bret Pettichord [EMAIL PROTECTED] wrote:
This will do the same thing, somewhat more simply.first_seen = truearray.each do |element|...if element == 'bar'if first_seenstart_col = 30first_seen = falseelse
start_col = 40endend...end
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

[Wtr-general] OT: Programming/Ruby Logic question

2006-10-27 Thread Paul Carvalho
Hi there, I've been staring at a piece of code trying to get it to work for a while and I think I need a break. I have just one piece of the puzzle left to figure out and it's not really a Watir problem. Here's the problem simplified...
I have an array with changing contents that I'm working with. For example:array = ['foo', 'bar']array = ['bar', 'bar']-- The relative positions are important here. The *first* occurrence of 'bar' should be implied to be bar-1 and the second occurrence would be bar-2.
Now, the contents of these arrays are not only used to populate a text field on an input page somewhere, but they are also used as lookups in a spreadsheet to identify where the rest of the input data is. I'm trying to find a simple, elegant way to set the lookups but I'm running into a logic wall. (Very likely due to a lack of sleep.)
Here are the lines of interest pertaining to the array data above:start_col = 0...start_col = 30  if array[ position ] == 'bar' and ( something )start_col = 40  if array[ position ] == 'bar' and ( something_else )
-- The part I'm having difficulty with is the something and something_else. (FYI: 'position' is a local variable because these lines are in a loop that iterates through the elements of 'array'. So I need to tell the script that the first time you see 'bar' it means go to the first set of spreadsheet columns, but the second time you see it go to the second set of spreadsheet columns.)
I originally had something check to see if it was the first element in the array, but as you can see from the first example above, that's not necessarily true. Then I tried having something check to see if the spreadsheet cell data for bar-2 = 'None', but that's not necessarily true either (
i.e. see the second example).I'm just worried that I might have programmed myself into a corner. My request for help here is my last attempt at a way out before I rewrite a whole bunch of code so that this will work differently.
Renaming the array elements (i.e. the bar) to be unique would certainly solve this problem easily, but then it would break the code elsewhere.Any suggestions?Cheers. Paul C.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] OT: Programming/Ruby Logic question

2006-10-27 Thread Paul Carvalho
Nevermind. Problem solved. Nothing that a power nap and another hour of exploratory programming couldn't work out. ;-)I had to give my loop a 'memory'. Here's what I ended up doing:first_seen = true
array.each_index do | position | ... if array[ position ] == 'bar' and first_seen start_col = 30 first_seen = false elsif array[ position ] == 'bar' and ! first_seen start_col = 40
 end ...endThis works in this example because there are at most only two occurrences of 'bar' in the array.Now onto the next thing. Have a great weekend!Cheers. Paul C.
On 27/10/06, Paul Carvalho [EMAIL PROTECTED] wrote:
Hi there, I've been staring at a piece of code trying to get it to work for a while and I think I need a break. I have just one piece of the puzzle left to figure out and it's not really a Watir problem. Here's the problem simplified...
I have an array with changing contents that I'm working with. For example:array = ['foo', 'bar']array = ['bar', 'bar']-- The relative positions are important here. The *first* occurrence of 'bar' should be implied to be bar-1 and the second occurrence would be bar-2.
Now, the contents of these arrays are not only used to populate a text field on an input page somewhere, but they are also used as lookups in a spreadsheet to identify where the rest of the input data is. I'm trying to find a simple, elegant way to set the lookups but I'm running into a logic wall. (Very likely due to a lack of sleep.)
Here are the lines of interest pertaining to the array data above:start_col = 0...start_col = 30  if array[ position ] == 'bar' and ( something )start_col = 40  if array[ position ] == 'bar' and ( something_else )
-- The part I'm having difficulty with is the something and something_else. (FYI: 'position' is a local variable because these lines are in a loop that iterates through the elements of 'array'. So I need to tell the script that the first time you see 'bar' it means go to the first set of spreadsheet columns, but the second time you see it go to the second set of spreadsheet columns.)
I originally had something check to see if it was the first element in the array, but as you can see from the first example above, that's not necessarily true. Then I tried having something check to see if the spreadsheet cell data for bar-2 = 'None', but that's not necessarily true either (
i.e. see the second example).I'm just worried that I might have programmed myself into a corner. My request for help here is my last attempt at a way out before I rewrite a whole bunch of code so that this will work differently.
Renaming the array elements (i.e. the bar) to be unique would certainly solve this problem easily, but then it would break the code elsewhere.Any suggestions?Cheers. Paul C.


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

Re: [Wtr-general] Wtr-general Digest, Vol 35, Issue 27

2006-10-25 Thread Paul Carvalho
Hmm, that's an interesting problem. When I first evaluated Watir to see if it would work with our .Net web app, it was important to figure out how to work with our tree control. Each tree control/library out there is different and none of the referenced examples that I could find worked for me.
Using IRB, I tried clicking through the images, clicking on text, there were no table cells to work with for me, tried clicking the DIV tags, and in the end I found that I could click on the 'SPAN' tags. It was tricky because none of the span tags had identifiable ID or NAME labels (
i.e. they were all blank). But where there's a will there's a way, and knowing that clicking on the SPAN tags worked, I found a way to work around the fact that none of them were labelled.Scanning through your code below, I see that the tree control appears in a single table row/cell. It does have images associated with each of the menu options though. That is, it looks like these images are associated with the menu options:
- ico_attachment_pencil_24.gif -- Code Groups- ico_admin_add_16.gif -- Key Person Detail- ico_calendar_16.gif -- Holiday Calendar- etc.Does clicking any of these images in that frame do what you need?
On 25/10/06, Roger Studner [EMAIL PROTECTED] wrote:
This is going to be messy.. but testing ASP.NET stuff:Here is the HTML.. this is the 'left frame' of my application.. the frame's name is contents
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 
4.0 Transitional//EN html head[snip] 
   trtd valign=top align=left?XML:NAMESPACE PREFIX=TVNS /?IMPORT NAMESPACE=TVNS IMPLEMENTATION=/webctrl_client/1_0/treeview.htc /
tvns:treeview id=tvObjectList class=testTree defaultStyle=font-size:11px;font-family:arial;font-weight:normal; imageUrl=../../images/ico_C_world_16.gif selectedImageUrl=../../images/ico_C_world_16.gif selectedNodeIndex=0 HelperID=__tvObjectList_State__ systemImagesPath=/webctrl_client/1_0/treeimages/  if (
this.clickedNodeIndex != null) this.queueEvent('onexpand', this.clickedNodeIndex)  if (this.clickedNodeIndex != null) this.queueEvent('oncollapse', this.clickedNodeIndex)  if (
this.clickedNodeIndex != null) this.queueEvent('oncheck', this.clickedNodeIndex)  if (event.oldTreeNodeIndex != event.newTreeNodeIndex) this.queueEvent('onselectedindexchange', 
event.oldTreeNodeIndex + ',' + event.newTreeNodeIndex) tvns:treenode Expanded=True Selected=true NavigateUrl=ObjectSinglePage.aspx?ObjectId=176amp;ObjectName=Code Groupsamp;TreeSeq=53amp;moduleid=20 ImageUrl=/SBSDEV/Images/ico_attachment_pencil_24.gif SelectedImageUrl=/SBSDEV/Images/ico_attachment_pencil_24.gif Target=detail ID=53
  Code Groups /tvns:treenodetvns:treenode Expanded=True NavigateUrl=ObjectSinglePage.aspx?ObjectId=155amp;ObjectName=Key Person Listamp;TreeSeq=31amp;moduleid=20 ImageUrl=/SBSDEV/Images/ico_admin_16.gif SelectedImageUrl=/SBSDEV/Images/ico_admin_16.gif Target=detail ID=31
  Key Person Listtvns:treenode NavigateUrl=ObjectMultiPage.aspx?ObjectId=156amp;ObjectName=Key Person Detailamp;TreeSeq=32amp;moduleid=20 ImageUrl=/SBSDEV/Images/ico_admin_add_16.gif SelectedImageUrl=/SBSDEV/Images/ico_admin_add_16.gif Target=detail ID=32
   Key Person Detail  /tvns:treenode /tvns:treenodetvns:treenode Expanded=True NavigateUrl=ObjectSinglePage.aspx?ObjectId=157amp;ObjectName=Holiday Calendaramp;TreeSeq=33amp;moduleid=20 ImageUrl=/SBSDEV/Images/ico_calendar_16.gif SelectedImageUrl=/SBSDEV/Images/ico_calendar_16.gif Target=detail ID=33
  Holiday Calendar /tvns:treenodetvns:treenode Expanded=True NavigateUrl=ObjectSinglePage.aspx?ObjectId=160amp;ObjectName=Fiscal Calendaramp;TreeSeq=36amp;moduleid=20 ImageUrl=/SBSDEV/Images/ico_calendar_16.gif SelectedImageUrl=/SBSDEV/Images/ico_calendar_16.gif Target=detail ID=36
  Fiscal Calendar /tvns:treenodetvns:treenode Expanded=True NavigateUrl=ObjectSinglePage.aspx?ObjectId=158amp;ObjectName=Product Listamp;TreeSeq=34amp;moduleid=20 ImageUrl=/SBSDEV/Images/ico_books_16.gif SelectedImageUrl=/SBSDEV/Images/ico_books_16.gif Target=detail ID=34
  Product Listtvns:treenode NavigateUrl=ObjectMultiPage.aspx?ObjectId=159amp;ObjectName=Product Detailamp;TreeSeq=35amp;moduleid=20 ImageUrl=/SBSDEV/Images/ico_books_pencil_16.gif SelectedImageUrl=/SBSDEV/Images/ico_books_pencil_16.gif Target=detail ID=35
   Product Detail  /tvns:treenode /tvns:treenodetvns:treenode Expanded=True NavigateUrl=ObjectSinglePage.aspx?ObjectId=161amp;ObjectName=Vendor Listamp;TreeSeq=37amp;moduleid=20 ImageUrl=/SBSDEV/Images/ico_admin_16.gif SelectedImageUrl=/SBSDEV/Images/ico_admin_16.gif Target=detail ID=37
  Vendor Listtvns:treenode NavigateUrl=ObjectMultiPage.aspx?ObjectId=162amp;ObjectName=Vendor Detailamp;TreeSeq=38amp;moduleid=20 ImageUrl=/SBSDEV/Images/ico_admin_add_16.gif SelectedImageUrl=/SBSDEV/Images/ico_admin_add_16.gif Target=detail ID=38
   Vendor Detail  /tvns:treenode /tvns:treenodetvns:treenode Expanded=True NavigateUrl=ObjectSinglePage.aspx?ObjectId=163amp;ObjectName=Party Listamp;TreeSeq=39amp;moduleid=20 

Re: [Wtr-general] Error selecting links within nested iFrame?

2006-10-25 Thread Paul Carvalho
I'm running Watir 1.4.1 (from Windows Installer) and Ruby 1.8.4-16 on my main machine.I copied your iframe_nested.html files into my C:\Scripts\1.4.1\unittests\html folder, and renamed your rb file to frame_test_Ethan.rb and placed it in my unittests folder.
To begin with, I re-ran the standard 'frame-test.rb' file and it ran without error. (as expected)Then I ran your rb file and I got several Failures, but no UnknownObjectExceptions errors. I got four very specific test failures:
(1) test_normal_frame_text_link_clicks(TC_NestedIFrames) : Link in normal Frame using text failed to click.(2) test_normal_frame_id_link_clicks(TC_NestedIFrames) : Link in normal Frame using id failed to click.
(3) test_nested_iframe_text_link_clicks(TC_NestedIFrames) : Link in nested iFrame using text failed to click.(4) test_nested_iframe_id_link_clicks(TC_NestedIFrames) : Link in nested iFrame using id failed to click.
I found these errors weird, because if I use IRB, I can interact with these links without error. So I decided to try a variation of your script code to see what happens.I copied your tests and took out the assert part. That is, there are now test pairs like this:
 # Test to click the link def test_nested_iframe_text_link_clicks1   $ie.frame(testFrame1).frame(linksFrame).link(:text, test1).click end 
 # Test that expected nested iFrame contains link using text. def test_nested_iframe_text_link_clicks2   assert($ie.frame(testFrame1).frame(linksFrame).link(:text, test1).click, Link in nested iFrame using text failed to click.)
 end-- Now when I run the script again, the first test passes but the second one fails with the following error: 2) Failure:test_nested_iframe_text_link_clicks2(TC_NestedIFrames) [frame_test_Ethan.rb:172]:
Link in nested iFrame using text failed to click.nil is not true.-- I would suggest a different assert command, but either way I'm not getting the same errors you are. I am able to work with links in frames and nested frames as I would expect to.
Paul C.On 24/10/06, Ethan Jewett [EMAIL PROTECTED] wrote:
Bug submitted, but the situation gets curiouser and curiouser.Myunit test seem to indicate that I can't .click links in any frame.Ican't imagine that no one else has had this problem, so I have toassume that it's relatively unique to my setup.
The bug report is bug 113, link: http://jira.openqa.org/browse/WTR-113I've attached a modified frame_test.rb and the necessary .html files,so if someone feels like taking a minute to test, that would be
appreciated.I will continue investigate further and attempt to determine whetherthis shows up in Watir 1.5.EthanOn 10/23/06, Bret Pettichord [EMAIL PROTECTED]
 wrote: Ethan Jewett wrote:  These commands fail with the UnknownObjectExceptions:  $ie.frame(buttonFrame).frame(linksFrame).link(:text, test1).click
  $ie.frame(buttonFrame).frame(linksFrame).link(:id, link_id).click   Is this a known issue?I don't see it in the OpenQA database as far  as I can tell.I'll clean up my tests and send a modified frames unit
  test and the necessary HTML files if that is desired.  This sounds like a new problem. Please open a new bug report for it. Does this happen in Watir 1.5?
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] How do you access an image that doesn't have img in the HTML tag?

2006-10-05 Thread Paul Carvalho
Hello Eva,What output does the following command produce when executed at an IRB prompt?  ie.show_imagesOr if it's in a frame:  ie.frame(:name, 'framename').show_images
On 04/10/06, Eva [EMAIL PROTECTED] wrote:
Typically image have this tag...[snip] I know this isn't a typical image tag. I believe that is why I'm having these problems. Any suggestions to get this to work?
brbrThanks.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] Joining two variables

2006-10-03 Thread Paul Carvalho
Hello Astha, you would do it in Ruby just about exactly as you have suggested.I would suggest a minor change to your data content though. You should either remove the final slash (/) from the first variable, or the first slash from the second. Otherwise your built-up URL will look like:
 $about_url = 'http://www.google.com//intl/en/about.html' # the double-slash in the middle is undesirableWhenever you have doubt or want to play with some ideas, give them a try at the Interactive Ruby (IRB) prompt.
Cheers. Paul C.On 03/10/06, Astha Raj [EMAIL PROTECTED] wrote:
Hi All,This is what I want to do. I want the base URL of the site to be a variable and to get other pages, I could create varaibles attaching to the base. So that if I have to change the URL, I can simply change the base variable.
Is there any way I can do this – something like below?$base_url = 'http://www.google.com/'$about_url = $base_url + '/intl/en/about.html'Thanks for your help.Astha
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] regex url

2006-09-28 Thread Paul Carvalho
Technically, you didn't send us the full link in your post. You sent us only a part of the full link. Can you simplify your regex? That is, is this good enough? $ie.link(:url, /selectTerritory/).clickOccam's razor works for me. Keep it as simple as possible.
Paul.On 28/09/06, Adrian Lewis [EMAIL PROTECTED] wrote:
Hi,I am having difficulties using regex and clicking on a link.the full link is:_javascript_:PC_7_0_G6_selectTerritory('1',%20'select')the regex I am using is: $ie.link(:url, /_javascript_.*selectTerritory('1',%20'select')/).click
and I receive an UnknownObjectException
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] Managing the Watir Project -- Wikipedia entry

2006-09-26 Thread Paul Carvalho
Nice! Thanks. =)On 26/09/06, Sun [EMAIL PROTECTED] wrote:
Regarding documentation, please see: http://en.wikipedia.org/wiki/WatirI have updated this by creating an example information section, plus updating the base note, and adding links to External Links and See Also.

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

Re: [Wtr-general] cell access

2006-09-23 Thread Paul Carvalho
Umm.. I have no idea what you're talking about, Bill. th is just a td with some fancy formatting. I see no reason why a command like the following wouldn't work with Watir 1.4.1:irb ie.table(:index, 1)[1][3].flash
As with anything you do, there are usually a few ways to get to a particular object on a page. You could just try to use the table(..)[row#][col#].whatever approach, or you could try to just access the span tag directly (as you suggested) and completely ignore the table.
Luke, in order for us to know what kind of advice to offer, it might help for you to also tell us what you have tried. Including the section of html was good, but not enough. Is the table in a frame? Is the Action just a text label, or also a link? Trying to get to something is not always straightforward by zooming in on the target. Sometimes you have to step back and take in the big picture too.
Paul C.On 22/09/06, Bill Agee [EMAIL PROTECTED] wrote:
I don't think Watir (1.4.1, at least) has built-in support for the th tag.But if you know the index of that span in the document, you can getto it using $ie.span(:index, theIndex)Otherwise, if you really need to interact with the TH itself, you may
need to use Watir 1.5.x and its new XPath support (unless 1.5 alreadyhas a class for TH).The list archives have examples of using XPathto access unsupported elements.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] Unit tests failed.

2006-09-17 Thread Paul Carvalho
Hi Raghu, Thank you for sending the output files. I suspect the problem is because you installed Watir into the Program Files folder. I've found that Ruby sometimes works unexpectedly if there are spaces in the folder or file name.
If you try to reinstall Watir off the root directory (e.g. C:\Watir ), your last remaining errors may go away.Paul.On 17/09/06, Reghunath B
 [EMAIL PROTECTED] wrote:Hi Bret,
Thank you very much.I am attaching the command prompt details for Watir 1.4 core_tests.Also, I have downloaded 1.5 gem and ran the same. afterwards, I tried thecore_tests again. It shows 2 failures. I have attached the command prompt
details of that as well.Note: I tried to run the googleSearch example, it ran fine.Regards,Raghu
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] Unit tests failed.

2006-09-16 Thread Paul Carvalho
Hi Raghu, I believe this is a known issue with the 1.4.1 release. You can download the zip file for the previous (1.4) release to get the missing images subfolder.1. Go to: 
http://rubyforge.org/frs/?group_id=1042. Download the watir-v1_4.zip file3. Open the zip file and copy the watir-v1_4/unittests/html/images folder to the 'unittests/html' folder on your hard drive
4. Re-run the unit tests.That should work.Paul C.On 16/09/06, Reghunath B [EMAIL PROTECTED]
 wrote:Hi,I installed Watir 1.4.1 and tried to run the unit test all_tests.rb
Towards the end, I got an error message that triangle.jpg file could not befound in /html/images/ directory. There is no such directoty as /images inthe folder /unittests/html.Also, the command prompt said182 tests, 616 assertions, 6 failures, 79
errorsPlease let me know how to solve this issue.Raghu
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] Do you want Watir to be more popular?

2006-09-15 Thread Paul Carvalho
On 15/09/06, Bret Pettichord [EMAIL PROTECTED] wrote:
A couple of recent posts were premised on the assumption that we wantWatir to be more popular? Do we? Why?I say 'yes', we do want it to be more popular. Here's my reason why.I first started out in this industry as a programmer for several years, almost 18 years ago. I then moved into Support for a while (swing that pendulum!) and finally into QA/Test in the early 90's. My programming skills definitely fell behind as newer, cooler, more powerful programming languages and methodologies began to appear on the scene. I was always intimidated by Object-Oriented programming, and I must have tried a dozen times to pick up Java, _javascript_, Perl, and Python over the last decade. I came close to Python, but it never really 'stuck' with me.
Over the last few years I've heard Brian Marick go on and on about Ruby and how it is the best scripting language for testers. I thought about giving it a try but it wasn't until Watir was recommended to me on a testing forum that I finally gave Ruby a look. The problem I needed to solve at the time was that I needed some simple performance measurements for a web site that I was testing -- I needed benchmark numbers to compare against the performance of development builds.
I was a little hesitant about trying another scripting language, but I must say that Watir made my life a whole lot easier. I had tried OpenSTA last year and failed to get it completely working with our .Net apps. Watir was different. It didn't care about Viewstates and Gets and Posts - it talked directly to the browser! And the scripts themselves are so readable that you'd swear you're reading pseudo code!
I must say that thanks to the hard efforts of everyone who contributed to making Watir possible, I now find myself programming in a powerful, object-oriented scripting language in order to complement my manual testing methods. With the advice from many wonderful people on this mailing list, my interest in the scripting has gone beyond Watir to explore more of what Ruby has to offer.
I've been bitten by the programming bug again and it's entirely due to the fact that Watir has made scripting fun and easy for me. My scripts may seem a bit loopy to a seasoned programmer, but I'm happy with them and so is my boss, the VP of RD at the company I'm currently working at. In fact, some of the scripts we've developed might even get adapted to be used by our Professional Services team too.
Because of Watir, our testing bandwidth has increased. For example, investing some time in some simple scripts now allows us to quickly populate large forms (e.g. with ~ 100+ input fields) with random data so that we can proceed more quickly with our manual testing.
Watir made it possible for me to get where I am, not Ruby on it's own. You've got a great thing going here. You need to continue to spread the word and show more testers out there how simple it is to get up and running with their own scripts to become more productive, effective, and valuable to their companies.
Thank you, Bret and Paul and all the others. Your hard work is making an impact in the Testing community and beyond. Keep up the great work and continue to spread the word!Cheers.Paul Carvalho

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

Re: [Wtr-general] I am a newb

2006-09-01 Thread Paul Carvalho
On 01/09/06, Phlip [EMAIL PROTECTED] wrote:
To the Ruby users: Where's the nearest ProgrammingRuby.chm for the OP?Does Watir come with it?Should be installed with Ruby itself. On my hard drive, I found a copy located in the /ruby/doc folder.

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

Re: [Wtr-general] Global Variables

2006-09-01 Thread Paul Carvalho
Is it called Duck Typing when Ruby figures out the variables as it goes along?That totally rocks. I only declare things as I need them in my scripts, and if my tests didn't run sequentially I would be totally screwed. =)
On 01/09/06, Chris McMahon [EMAIL PROTECTED] wrote:
Perl forces you to understand scope of variables fairly early (unless you write bad Perl using package variables, not lexical variables, and don't use warnings and don't use strictures, in which case you can ignore everything that follows): unless you declare variables' scope the first time the variable is used, the compiler gives you a warning. Variables declared within a routine with my $var are available only to that routine; variables declared outside routines with my $var are available to all subroutines declared in that scope. 
Global variables are designated by our, not my. our $var is available to all routines in the program. Managing this sometimes gets tricky. One of the most popular Perl FAQs of all time is Coping with Scoping: 
http://perl.plover.com/FAQs/Namespaces.html
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] OT: Ruby FTP behind a Firewall

2006-08-25 Thread Paul Carvalho
Aha! Thanks Chris. My google searches didn't turn up that hit.Unfortunately, it gets me one step further but I still cannot connect:irb(main):001:0 require 'net/ftp'= trueirb(main):002:0 ftp = Net::
FTP.new= #Net::FTP:0x2bee920 @mon_owner=nil, @debug_mode=false, @mon_waiting_queue=[], @passive=false, @binary=true, @mon_entering_queue=[], @mon_count=0, @resume=falseirb(main):003:0 ftp.passive
 = true= trueirb(main):004:0 ftp.connect('ftp.cs.uiuc.edu')Net::FTPPermError: 530-530-Your hostname cannot be confirmed via the nameserver.530-530-
530- -- ACCESS DENIED --530-530-530-530 from c:/ruby/lib/ruby/1.8/net/ftp.rb:243:in `getresp' from c:/ruby/lib/ruby/1.8/net/ftp.rb:251:in `voidresp' from c:/ruby/lib/ruby/1.8/net/ftp.rb:176:in `connect'
 from c:/ruby/lib/ruby/1.8/monitor.rb:229:in `synchronize' from c:/ruby/lib/ruby/1.8/net/ftp.rb:174:in `connect' from (irb):4irb(main):005:0 ftp.connect('
ftp.ruby-lang.org')= nilI'm going to go back to our IT guy and see if he can shed anymore light as to why I'm getting this error. Google didn't turn up anything helpful to me when I tried searching on that specific ftp error message.
Cheers. Paul.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] OT: Ruby FTP behind a Firewall

2006-08-25 Thread Paul Carvalho
Hoo-ahh! Got it! After much convincing, I managed to get our IT guy to look into the problem in more detail. This is what he wrote back to me:I did find one thing. They may be doing a reverse DNS lookup (our outgoing IP) and then seeing if that IP has an A record. We didn't have an A record for one of our hosts. I have made this change on our external DNS so in a few minutes (possible not for a few hours) we can try again and it might work.
I tried the Ruby FTP commands again and the error is gone! Now I can relax and enjoy my weekend. =)Take care and have a great one! Cheers. Paul.On 25/08/06, 
Chris McMahon [EMAIL PROTECTED] wrote:
2) This: Net::FTPPermError: 530- 530-Your hostname cannot be confirmed via the nameserver.looks very much like a DNS error.If you can get your IT guy to fixthe nameserver, great, if not, try editing your hosts file (in XP,
found at C:\WINDOWS\system32\drivers\etc\hosts, of all places.I hateWindows sometimes)on the FTP client machine.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] method which contains array as the parameter

2006-08-21 Thread Paul Carvalho
You can also use the each method... as in:def run_check_links(ieHelper, arrayText) arrayText.each do |link_text|   assert(ieHelper.link(:text, link_text.exists?)   assert(ieHelper.link
(:text, link_text.enabled?) assert_equal(link, ieHelper.link(:text, link_text).type ) endendOn 21/08/06, sikander 
[EMAIL PROTECTED] wrote:










this method is restricted to check for only 3 specific
links. But I want to define array[] as the parameter, and I want to pass any
number of links and verify it. 



Here is what I want to do



def run_check_links(ieHelper, arrayText[])
 i=0

 while
i = arrayText.length-1

 assert(ieHelper.link(:text,
arrayText[i]).exists?)

 assert(ieHelper.link(:text,
arrayText[i]).enabled?)

 assert_equal(link,ieHelper.link(:text,
arrayText[i]).type )

 i+=1

 end

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

[Wtr-general] Regex string comparison

2006-08-15 Thread Paul Carvalho
Hi there, I'm still a novice when it comes to using regular expressions and am having a bit of difficulty figuring out the syntax on the following problem.Here's what I want to do:- I'm trying to create a branch in the code if the PageHeadingLabel contains one of two words.
Here's the line that I've tried: if t_ie.span(:id, /PageHeadingLabel/).text.include?( /Create|Update/ )This doesn't work. When I try it in IRB, I see the following message:---TypeError: can't convert Regexp into String
 from (irb):7:in `include?' from (irb):7 from :0---Suggestions? I really didn't want to use two comparisons, one for each word. There must be an efficient way to do this, yes?
Paul.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] Regex string comparison

2006-08-15 Thread Paul Carvalho
Sweet! Worked like a charm. Thanks. Learned something new today. I guess I can go home now. ;-)Cheers! Paul.On 15/08/06, Dave Hoover 
[EMAIL PROTECTED] wrote:Yep, use the String#match method.
http://www.ruby-doc.org/core/classes/String.html#M000583
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] Navigating in IE frames

2006-08-10 Thread Paul Carvalho
Yes, you do need to specify the frame. Try something like: ie.frame('FrameName').text_field(:name, inpListFilter ).set(adm )You should be able to incorporate the FrameName into your 'ECMTestFixture' object.
To see the frames that Ruby/Watir sees, try the following at an IRB prompt: ie.show_framesOn 10/08/06, Dave Munns 
[EMAIL PROTECTED] wrote:Hi. I am building a test tool to automate navigation through a UI with IE frames. Text fields, buttons, lists, and web dialog boxes are all targets for my tool.The examples I see in the watir user guide don't mention frames. I have tried navigating to a text field, using the user guide example, but watir complains that my text field identifier (inpListFilter) is not found (I identified it with SpySmith). Do I have to qualify the identifier with a frame name or set the frame context ?
Here is the offending line:ECMTestFixture.text_field(:name, inpListFilter ).set(adm )
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] Incrementing object names

2006-08-08 Thread Paul Carvalho
I use similar mixed variables in my scripts but I use the 'succ' method rather than trying to manually figure it out.For your sample code below, I might rework it to something like:def enter_data x = 0 ; object_name = 'A10'
 read_in_test_data... ... object_name.succ! p object_name ...endHope this helps. Paul.On 08/08/06, aidy rutter
 [EMAIL PROTECTED] wrote:
At the moment I am trying to add 0 or 1 onto 'A11' like this  def enter_data x=0 read_in_test_data.each { |x|  line = x.chomp  next if line.upcase == 'ADDRESS:' 
 object_name = 'A'  #{11+x}  p object_name $ie.text_field(:name, object_name).set(line) x+=1 } end 
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] Watir, file_field, dojo and VMware

2006-07-27 Thread Paul Carvalho
I have used VMware with Watir successfully. I've got a WinXP Pro SP2 VMware session that has IE7 Beta 2. On it, I have Ruby 1.8.4 and Watir 1.4.1.I just ran the UnitTest filefield_test.rb and it executed without error.
I can't say I really understand what the problem described below is, so I can't offer any suggestions right now.Paul.On 26/07/06, Bret Pettichord
 [EMAIL PROTECTED] wrote:
What is a ruby attach dialog?I'd be surprised if vmWare itself is the source of your problem. I'm pretty sure we have people here who have used it with Watir successfully. True?Bret

On 6/26/06, John Castellucci [EMAIL PROTECTED] wrote:


















Howdy all – I have some Watir tests
that invoke the file_field field object, and I've noticed some slightly
odd behavior when running on native WinXP vs. virtual
WinXP through VMware.



If a regular page has a file_field control,
everything works peachy.



But, the application also has pages where you
can click a button and it opens a dojo (a _javascript_ toolkit) modal faux popup
with the file_field (the underlying page is disabled), and this is where I see
the weird behavior.



When invoking field_field.set(), only the ruby
attach dialog opens – the standard IE File Upload dialog *does not* open. It's not until the attach dialog
closes that the IE File Upload finally appears, and at this point, the Watir
script hangs. (I suspect because there was no File dialog for
ruby to attach to).



If I were to take a stab in the dark, I would
say it might have something to do with how VMware manages
threads – dojo, ruby and IE are all fighting over processes, and IE is
the loser…



Anyone ever run into behavior like this
before?










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

Re: [Wtr-general] problem in click event of div

2006-07-21 Thread Paul Carvalho
Hi Vikash,Maybe your code is working. Maybe it just doesn't do what you think it should do.Are you trying to access the checkbox? If so, why not just try something more direct like: ie.checkbox(:id, /3_1/).flash
 ie.checkbox(:id, /3_1/).setOn 22/07/06, VIKASH KUMAR [EMAIL PROTECTED] wrote:
   div id=tCt2 dojoType=ContentPane label=Common style=width: 
760px; div class=permissionList  label class=chk
 for=""> input type=checkbox id=assignedSystemGroups_3_1 class=chk name=assignedSystemGroups value=baseWebAccess 
 Login to Web Application /label /div  I wanted to click on div having id=tCt2, the below code is not working:   ie.div
(:id,tCt2).flash ie.div(:id,tCt2).click 
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] for loop syntax??

2006-07-19 Thread Paul Carvalho
Ruby rocks! My fav is: 9.times{|x|putsx}It doesn't get any clearer for me than just telling it how many times I want it to loop without worrying about extra syntax that I'm likely to get wrong.. ;)
On 19/07/06, Chris McMahon [EMAIL PROTECTED] wrote:
On 7/19/06, mi [EMAIL PROTECTED] wrote: ahhh, That was it!!!I'm just NOT used to start an iteration form 0:-(THANKS a millionRuby folks don't generally use for loops:
1.upto 9 do |x|puts xendruby loop.rb123456789Exit code: 0
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] Watir Users forum at forums.openqa.org

2006-06-21 Thread Paul Carvalho
Yes, I think it would be a great idea.On 21/06/06, Bret Pettichord [EMAIL PROTECTED] wrote:
Zeljko,The plan has been to rename that forum Watir General and then to set up a mirror (or whatever you call it) between this list and that forum. Thus everything that is posted here would show up there and everything that was posted there would show up here.
I think the only blocker has been that I haven't had the time to follow this up with OpenQA. Would you mind arranging the details with Patrick Lightbody?Do we have agreement on the list that this would be a good thing to do?
Bret
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] tag a name to an assertation

2006-06-14 Thread Paul Carvalho
I recommend Zeljko's one-line assert statement, but *if* you really want to keep the format you have now, you can also use the 'flunk' command.For example:if $ie.select_list(:name, 'criteria.countryId').exists?
assert(true) else flunk( select_list(:name, 'criteria.countryId') does not exist ) endOn 14/06/06, Adrian Rutter 
[EMAIL PROTECTED] wrote:Hi,Is it possible to tag a name to an assertation, so if I run this:
if $ie.select_list(:name, 'criteria.countryId').exists?assert(true) else assert(false) endif $ie.select_list(:name, 'criteria.lob').exists? assert(true) else assert(false) endAnd one passes and one fails, I can pinpoint and log which one has failed,
instead of just getting this1 tests, 1 assertions, 1 failures, 0 errorsCheersAidy
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

[Wtr-general] How do I set the end of a string to a variable?

2006-05-16 Thread Paul Carvalho
Okay. I know that I should know this, but knowing that doesn't mean that I know it. arrrg. This is a Ruby string manipulation question, not really a Watir question.I have this label on a web page - we'll call it PageHeadingLabel - and the contents change based on selected user. I need to know how to capture the *last* part of that string to a variable.
Here's the code that calls up the text: $main_frame.span(:id, /PageHeadingLabel/).textAnd the output is something like: Good Morning, user namee.g. Good Morning, Bob or Good Morning, Jamaican Bobsled Team or whatever.
I *need* to capture the user name to a variable (let's call it 'user_name')- I have looked through all the String class methods, but I haven't found anything straightforward that will help me output the last part of a random-length string. I managed to get the Element Reference [] to spit out what I need but it's kind of gross-looking (mostly because I don't want to work with intermediate variables).
I browsed through the Regular _expression_ stuff, but I still haven't had a chance to read up on it. My amateur re commands keep returning true, false, nil, etc. but not actual strings.Does anyone know of a simple way to set a variable to something like this:
 user_name = $main_frame.span(:id, /PageHeadingLabel/).text (from ', ' to the end)?help. please.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

[Wtr-general] OT: How to Navigate the Watir FAQ

2006-05-11 Thread Paul Carvalho
Hi there, this is totally aside and just 'FYI' so please disregard if you are not interested.It's been bugging me for a few weeks so I just took a look and discovered why the anchors to the FAQ haven't been working as expected. Here's an example -- Bret sent out the following link in a recent email:
 http://wiki.openqa.org/display/WTR/FAQ#concurrent-ieI followed the link, and like other similar links, I am brought to the *top* of the FAQ page, but not the actual intended section. (unexpected)

I browsed the 'code' on the page and you will see the following line just above the corresponding section: {anchor:concurrent-ie}-- I think the assumption here is that you would form the URL by simply adding a # in place of the 'anchor:', but this is not how this code is actually translated to HTML.
First off, all the dashes are removed from the actual HTML. So the anchor will really be identified as concurrentie.Next, for some reason, the page Title is being *prefixed* to the real anchor.
This means that the anchor name is actually: #FAQ-concurrentieSo, to go to that section of the FAQ, you would have to follow this URL: http://wiki.openqa.org/display/WTR/FAQ#FAQ-concurrentie
Using another example, another popular section that is often referenced is the Access denied when trying to access a frame. This has the following corresponding 'code': {anchor:access-denied}
Therefore, to access this URL you would use the following: http://wiki.openqa.org/display/WTR/FAQ#FAQ-accessdeniedI thought some of you might be interested to know this.
Cheers. Paul.(no, the *other* Paul. ;))
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] OT: How to Navigate the Watir FAQ

2006-05-11 Thread Paul Carvalho
Really? I tried the corrected links on IE6 in WinXPSP2 before I posted my observations and they work for me. Mind you, I always get a few Runtime Errors when I try to connect to that page with IE6 for some reason, but the FAQ and correct section *do* appear.
That is strange. Oh well.Paul.On 11/05/06, Boyt, Darrel 
[EMAIL PROTECTED] wrote:
Paul (and anyone else who's interested),I tried the corrected links you supplied in IE6, Firefox 1.5.0.3, and
Opera 9.00 Beta Build 8367.The links worked as you said in Firefox and
Opera, but not in IE.Kinda weird...Darrel
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] frame.html fails in development version

2006-05-10 Thread Paul Carvalho
This is a known problem in 1.5. The description is perhaps not clear enough to be found by a search, but it is in JIRA: http://jira.openqa.org/browse/WTR-13Technically, there's nothing wrong with the google_maps.rb script... it just fails because the 
frame.html fails in the script.Paul.On 10/05/06, David Schmidt [EMAIL PROTECTED] wrote:
I have some code which was using Frame#html which was inherited fromWatir::IE in 1.4.
In 1.5 this broke because Frame is no longer inherited from IE.I movedWatir::IE#html to the Container module and now it's working fine becauseboth Watir::IE and Watir::Frame include Container.

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

Re: [Wtr-general] Order of execution for ruby tests with test/unit

2006-05-04 Thread Paul Carvalho
Hi George, it's been my experience that the unit tests run in what appears to be an alphanumerically-ascending order. It's been a while since I've looked at it, but I think this is the general pattern. (This is all off the top of my head, but I'm sure I can easily confirm it. I still have the scripts lying around somewhere that gave me this info.) This might be academic to some but it was enlightening to me so I thought I'd share it since you asked. 
(BTW, please forgive me for not using correct Test case/suite/whatever terminology here.. I don't have my Ruby/Watir references handy as I type this.)Let's say that you have a master script that calls 3 other scripts that have the test classes in them.. something like:
---# Setuprequire 'watir'require 'test/unit'# Set up common methods, variables, whatever# My Testsrequire Startup.rbrequire HomePage.rbrequire ShutDown.rb---The imaginary contents of '
Startup.rb' could be something like:---class Test_Startup  Test::Unit::TestCase ie = Watir::IE... puts 'This is the start' def test_navigation ie.goto(..) ie.blah.blah assert_equal(yadda, yadda)
 end def test_login ie.text_field().set()  end puts 'This is the end.'end---And so on. You can assume that a similar pattern exists for the other two scripts. Here's where it gets fun.
My initial, uneducated, guess was that these tests would run in the following order:1) Startup.rb a) test_navigation b) test_login c) ...
2) HomePage.rb a) .. b) ...3) ShutDown.rb a) ..
 b) ...
Ya, well, reality was something a bit different. That is, I found out that these tests are supposed to run in a 'random' order.I didn't believe for one second that Ruby was really going to run these tests randomly so I tried to figure out what the pattern actually was. Here's what I found out.
First of all, the code is put into two 'pools': (1) Stuff not in a 'test' definition (i.e. *not* a test), and (2) stuff that's in a test definition (i.e. the tests).- All the non-test stuff is executed first, in the order in which they appear.
So, all the lines in the Master script are run first, as you would imagine, followed by the lines it finds in the test scripts that aren't in 'test' definitions either. That means that the following lines will be executed *before* any tests are run, even though they're within test classes:
--- ie = Watir::IE...
 puts 'This is the start'
 puts 'This is the end.'
---
Next, all the Test Classes are put into alphanumeric order. So regardless of how I called the scripts above, they will be run in the following order:---class Test_HomePage  Test::Unit::TestCase
class Test_ShutDown  Test::Unit::TestCase
class Test_Startup  Test::Unit::TestCase
---Lastly, all of the test cases are sorted in an ascending alphanumeric order. So, given the two tests in my 'Startup' script above, they will actually run in this order:
 def test_login

 def test_navigation...and so on..To get around this, I've been using a naming convention for my test classes that include numeric labels. Something like this:---

class Test_01_Startup  Test::Unit::TestCase

class Test_02_HomePage  Test::Unit::TestCase

class Test_03_ShutDown  Test::Unit::TestCase---
- Which assures me that they will be run by Ruby in that order.Then I also use numeric labels similarly with the test case names too. That way, I know that they run in the correct order. So using my example from above, you would probably see something like this if you browse through my scripts:
---


class Test_01_Startup  Test::Unit::TestCase


 def test_0101_navigation


 def test_0102_loginclass Test_02_HomePage  Test::Unit::TestCase


 def test_0201_check_userdata



 def test_0202_check_reports
class Test_03_ShutDown  Test::Unit::TestCase ...
---

This way, I don't have to worry about which order the tests are run because I *know* that they will run from top to bottom, in the order that I specify the tests to run.I was quite happy to discover that pattern. I don't recall where I got the initial tip, but I'm pretty sure that someone or something mentioned that I should consider ascending labels.
Works for me. I would be happy to have someone confirm this pattern for me. As I said, it was a while ago that I figured this out (probably 4-6 weeks ago now), and I am just winging this off the top of my head, but I'm pretty sure I got the details correct.
Hope this helps. Have a great day!Cheers. Paul.On 04/05/06, George Flaherty 
[EMAIL PROTECTED]
 wrote:Sorry to repeat here, but did someone post a way to execute ruby unit tests in a predetermined order 
vs.the default random order?Thanks-george
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] Ruby IDE

2006-05-03 Thread Paul Carvalho
I've been using SciTE. Until now I haven't heard of Arachno Ruby.. maybe I'll check it out.Every time I try FreeRIDE it always disappoints me. I tried it again just now - it doesn't like my dual monitor setup (does weird things with the menus), and it hangs for some reason in the middle of my scripts. The scripts run perfectly when I run them from a command line or SciTE, so I blame the hack'ish IDE.
A good debugger would certainly be useful.On 03/05/06, Adrian Rutter [EMAIL PROTECTED] wrote:
Hi,I would like to find out what Ruby IDE you are using for your Watir tests.
I downloaded Arachno Ruby, but its debugger only supports upto Ruby 1.8.3.CheersAidy
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] Access Denied with Frames

2006-05-02 Thread Paul Carvalho
Just for the record, none of the advice in this FAQ entry have helped me get rid of this error. =(I'm not trying to navigate to a frame on another site, but the two outside (empty) frames are hosted on a separate resource web site. When I check the frames, I see the following output:
irb(main):128:0 ie.show_framesthere are 4 framesframe index: 1 --Access Denied--frame index: 2 name: FooBarframe index: 3 name: MainWindowframe index: 4 --Access Denied--= 0..3
I get these Access is Denied warnings randomly when I click buttons and follow links in the 'MainWindow' frame. This frame is hosted on the same site, so I don't know why the warning messages keep appearing.
I've tried everything in the FAQ but to no avail:1. Navigate directly to the subframe..-- Not relevant. I'm not navigating to a different subframe.2. Add host to the Trusted Sites list.
-- Did it. No effect. Warnings still appear.3. Place entry in Hosts file.-- Same as (2) - no effect.4. Set IE to Low Security Level zone setting-- Can't do it. Corporate Security Policy enforces a minimum Medium value, so I can never set it to Low.
This is why I need to spend time figuring out how to write the UnitTest output to a file -- so I can eliminate all these annoying Warnings. I even tried launching ruby with a quiet verbose setting but it had no effect. I have been totally unable to suppress these warnings.
In the end I've come to live with them, but I can't help but think that there must be something that can be done in the code to suppress these Warnings. Unfortunately, I'm too focussed on testing and/or solving the scripting problems to figure out how to eliminate these errors. They're annoying but so are mosquitos in the summer time. Oh well.
Just thought you should know that the FAQ entry doesn't help me in my situation.Paul.On 02/05/06, Bret Pettichord 
[EMAIL PROTECTED] wrote:I've changed this error message to say
Access Denied, see http://wiki.openqa.org/display/WTR/FAQ#FAQ-Accessdeniedwhentryingtoaccessaframe
Please rephrase this wiki page if you have a better suggestion for the advice people should get in this situation.Bret
On 5/2/06, 
Michael Bolton [EMAIL PROTECTED] wrote:

It clearly helps some people.I wonder if the error message could includethe suggestion to add the server to the trusted site?(I'll volunteer tohelp with the writing of it.)---Michael B.

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

Re: [Wtr-general] The Watir Installer

2006-05-01 Thread Paul Carvalho
You could also create a batch file called 'install.bat' that simply has the gem install watir command.On 01/05/06, Bret Pettichord 
[EMAIL PROTECTED] wrote:
Harry,Just download the gem the way you would download any other file.Then you need open a command window, and cd to the directory containing the file.Then you type gem install watir. This command will first look in the current directory for the gem before searching for it over the internet.
We will have to clearly document this procedure for those users who are new to Watir and Ruby and behind firewalls.Bret
On 5/1/06, Harry Chou
 [EMAIL PROTECTED] wrote:
For using this command:
gem install watir -p http://[EMAIL PROTECTED]:proxy-urlWhat should I do if my username or password contains a @ character?
On 5/1/06, Harry Chou 
[EMAIL PROTECTED] wrote: Alright. I haven't try that. I will give it a try. Thanks. On 5/1/06, Dave Burt 
[EMAIL PROTECTED] wrote:  Harry Chou wrote:
   On 5/1/06, Harry Chou [EMAIL PROTECTED] wrote:   I don't think GEM works easily behind Firewall/Proxy. Am I not right?
   I know there perhaps are ways to get it working. I am just arguing
   that this will prevent people from JUST trying Watir.   You can easily download the gem and install it locally. I don't think it  should be a deterrent, especially if this info is easily available.
   Cheers,  Dave  ___  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 listWtr-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 can I read alternate field attributes into a variable?

2006-04-26 Thread Paul Carvalho
Hi Zeljko, Yes. That's what I need. Seems obvious now - I can't believe I didn't find it in the API reference.Cheers. Paul.On 26/04/06, Zeljko Filipin
 [EMAIL PROTECTED] wrote:
I guess that you will know how to assign it to variable and use thatvariable (if I am wrong, let me know). :)irb(main):006:0 ie.text_field(:name, /UserName/).maxLength= 50
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

[Wtr-general] Need Help redirecting the Test Unit output

2006-04-25 Thread Paul Carvalho
Hi there, I'm trying to capture the Test Unit output to a file but I'm not exactly sure of what it is I need to capture. I thought it was STDOUT, but now I'm not so sure. Here's an example of what I want...In the Watir\Unittests\ folder, run the script: iostring_test.rb
It has the following output:ruby iostring_test.rbLoaded suite iostring_testStarted..Finished in 0.0 seconds.6 tests, 7 assertions, 0 failures, 0 errorsExit code: 0
This script redirects STDOUT (the 'puts' and 'prints') to variables to work with them in the asserts. That's neat, but not what I want to do.What I actually want to do is capture the *above* Test Unit summary output to a file and ignore everything else. I want the Loaded, Started, , Finish time, and test summary.
I've searched the Watir message archives, googled the web, and skimmed through the PickAxe book, but so far I haven't been able to figure out how to do this. I browsed through some of the code in C:\ruby\lib\ruby\1.8\test\unit but I haven't deciphered it yet.
Does anyone know how to redirect this Test Unit output? Are there any additional sources that I can refer to for changing the Test Unit framework so that it writes this info to a file?Paul.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] Need Help redirecting the Test Unit output

2006-04-25 Thread Paul Carvalho
That's a fair question. I'd like a bit more control over what output I actually save to file. For instance, the web app under test has frames where some of them return the 'Access is Denied' warnings. I'd like to weed out all that crap.. err, noise.. and just see the test summary.
The output request was actually a requirement from my boss. He asked to have an output that just summarises the tests run and doesn't output anything else unless something goes wrong. Since I can't prevent the 'Access is Denied' warnings from appearing in the console, I'd like to find a way to just redirect the Test Unit information to a file and ignore everything else.
P.On 25/04/06, Daniel Browne [EMAIL PROTECTED] wrote:
What happens if you do:ruby iostring_test.rb  some_file.logOr to redirect STDOUT and SDTERR to the file try:ruby iostring_test.rb  some_file.log 21Cheers,Daniel.

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

[Wtr-general] How can I read alternate field attributes into a variable?

2006-04-25 Thread Paul Carvalho
Most of my Watir scripts generate their own random inputs (content and length), but I always have to specify an upper limit for each data value specified.For example, a Create New User page has the following HTML for a User Name input field:
 INPUT class=fieldLarge id=_ctl0_UserNameField maxLength=50 name=_ctl0:UserNameField and the script writes to it with the following code: # Input a username that is at least 5 characters but no more than 50 chars in length
 $ie.text_field(:name, /UserName/).set( random_input( 'text', 5+rand(46) ) )So I have to [manually] specify in the script that it should contain no more than 50 characters in length (i.e. upper limit of 5+45).
I would like to know if it is possible to have Ruby/Watir automatically read the 'maxLength=##' attribute and assign that value to a variable that I can then work with in the corresponding input commands?If I can do that, then my scripts will be even more independent and free to generate their own inputs of random length based on what the HTML says a field's upper limit is.
I couldn't find anything in the Watir API Reference that looked like it might do this. Could we add a feature to do this if there isn't a way now?Paul.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] Saving HTML to output adds extra line feeds?

2006-04-21 Thread Paul Carvalho
Thanks for the replies Bill, but neither (write or print) seemed to work for me. That is, the output still had the extra line feeds.I decided to try removing the extra line feeds manually and it worked, so I'll go with that for now:
  f_e.puts html_content.delete( 10.chr )Cheers! Paul.On 21/04/06, Attebery, Bill 
[EMAIL PROTECTED] wrote:




Paul -- I tried these and they both seemed to do the
trick:

f_e.write
html_content
f_e.print
html_content


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

Re: [Wtr-general] Unable to Click on tab - any workaround??

2006-04-19 Thread Paul Carvalho
Thanks for sending the screenshot, but the bit of source code that you sent is only a list of functions -- it's not the HTML itself. Unless I'm reading it wrong, you should be looking elsewhere in the HTML source.
There are many different html elements that you can look for (e.g. tables, spans, divs, images, etc.). While the SCRIPT section that you sent may _look_ relevant, I don't see anything there that would place those functions or links anywhere on the web page. In fact, there isn't anything even in the code snippet you sent that links them to the labels that appear in the screenshot.
Have you tried SpySmith? What does the source code look like when you [ctrl]+[right-click] on a 'tab' in your page?That should give you a better clue as to how the web browser sees and displays that element.
Hope this helps. Paul.On 19/04/06, Anil Kumar Das [EMAIL PROTECTED] wrote:
Please findsource code  snapshot of application


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

Re: [Wtr-general] Can a link to the Watir licence be posted on the Watir homepage?

2006-04-18 Thread Paul Carvalho
I just added the License to the main page. I copied the License from the ReadMe in the Watir API Reference. Someone can update it if it's not the correct one or if there have been other changes made to it since it was first written (
e.g. does the Copyright year need to include 2006 now?).Hope this helps. Cheers. Paul. (the *other* Paul)On 18/04/06, Bret Pettichord 
[EMAIL PROTECTED] wrote:
This would be a great thing to put on the Confluence Wiki.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] Unable to Click on tab - any workaround??

2006-04-18 Thread Paul Carvalho
Hi there, you've given us some information about the problem, but not enough to provide you with an exact answer. One thing that I would recommend to you would be to spend some more time looking at the objects on the page to try and understand exactly how the tabs are placed on the page.
For example, in one of the web applications that I work with the tabs shown are actually laid out within two nested tables. By using IRB and various tries at ie.table(:index, #).flash I was able to find the table that holds the clickable tab graphics and links. I also discovered that there were extra, blank columns that I needed to avoid.
My actual script code looks something like this: # Find out how many Tabs are showing. (Column count - 2 ) / 2 = # Tabs tab_count = ($ie.frame('MainWindow').table(:index, 2).column_count - 2 ) / 2
  tab_count.times do |x| # click the tabs to find the desired page # The clickable 'tabs' are in columns 2, 4, 6... $ie.frame('MainWindow').table(:index, 2)[1][2*(x+1)].click rescue true sleep 1
 break if $ie.frame('MainWindow').span(:id, /foo/).text == 'bar' endIt took me a few minutes to work out the math, but the pattern was repeated throughout the application so it was time well spent. There might be different ways to do this, but that's what I came up with at the time.
I'm just offering this as an example. You will need to figure out how your tabs are laid out on your application's web page and find a good way to script the steps.If there's one thing I've learned, it's that if I can click it with a mouse, I can automate it with Watir!
Good luck!Paul.On 18/04/06, Anil Kumar Das [EMAIL PROTECTED] wrote:
I have a web application for SALES ORDER Module
-Order Detail | Parties |Line Items-Onclick of order detail application opens 10-20 fields to add order information, party tab shows 10-20 fields to enter party information and Line Items shows fields to enter product details

When I saw source code of this web page I found .. 
displayZerothTab,displayFirstTab,displaySecondTab were the variables which takes values of onClick from user action
I tried all possible following combination but couldn`t solve this issue# $ie.link(:url, ).click# $ie.button(:name, ).click$ie.image(:src, ).click$ie.link(:text, ).click
$ie.image(:text, ).click$ie.link(:scr,).click$ie.link(:url, ).click$ie.attach(:title,).click
with displaySecondTab  Line Items (lebal of this tab)
I was wondering if there is any workaround for clicking Tab like button,image,url etc in watir??Waiting for reply


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

Re: [Wtr-general] SciTE Repeats Input Chars in IRB

2006-04-04 Thread Paul Carvalho
Hello Eli, there's a lot of information you didn't offer to allow us to help you better.What version of Ruby are you using (so we know the version of SciTE)? What version of Watir?How are you executing the scripts? Which input chars are being echoed? Can you include a sample of your code and the corresponding annoying output?
Help us out a bit here. ;-)Cheers. Paul.On 04/04/06, Eli Smith [EMAIL PROTECTED]
 wrote:
















Greetings, Rubyists.

Ruby newbie here with an SciTE question.

How do I stop SciTE from repeating my
input chars in IRB?

I can't figure out which bit to flip
off but it's got me crazed.

The suggestions at 
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/143959
didn't solve it.



adTHANKSvance,

~Eli- 












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

Re: [Wtr-general] SciTE Repeats Input Chars in IRB

2006-04-04 Thread Paul Carvalho
Ah, now I see. I am using Ruby 1.8.4-16 with SciTE 1.67. There is *no* Run irb under the Tools menu.I guess it didn't work so they took it out. Sorry. Looks like you'll have to CMD-prompt it to work around this problem.
Cheers. Paul.On 04/04/06, Eli Smith [EMAIL PROTECTED] wrote:














Fair enough, Paul. Lemme spill my guts.

I'm using Ruby 1.8.2, Watir 1.4.1,
and SciTE 1.59 on a Winserver 2003 with SP1.

To see the problem:


 Start
 SciTE on Windows.
 Select
 Tools  Run irb from the menu system.
 Type
 into the command window provided.


Each character entered it displayed twice.
Guess what this is?

rreeqquuiirree ''wwaattiirr''



Makes you wanna start a command prompt!

Any known workarounds? I like the near-IDE
SciTE provides.



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

Re: [Wtr-general] SciTE Repeats Input Chars in IRB

2006-04-04 Thread Paul Carvalho
Hi Eli, you can execute your scripts from within SciTE too. Just press [F8] to see the output pane and press [F5] to run the script. The output pane shows you the output that you would normally see in a command window. No need to run it separately.
Hope this helps. Paul.On 04/04/06, Eli Smith [EMAIL PROTECTED] wrote:















Thanks for the input, all. And I see your
point, Mark. I'll have to get more comfortable in Windows non-UNIX command
line. 

So it sounds like the preference is for editing
with SciTE (or editor of choice) and execution from the command line. I think
my environment needs some work.~Eli-
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

[Wtr-general] OT: Line Order in Scripts and Writing File Output

2006-03-22 Thread Paul Carvalho
Hi there, please forgive the Off-Topic question. Let me know if I should try another forum or resource (and which ones they are).I'm trying to refactor one set of Watir scripts into separate files so that it is more like the setup used in the UnitTests and I seem to be having some difficulty figuring out the right order of things. Maybe it's just the choice of my files that's hanging me up, but it's what I'm working with so I'd like to see if I can figure it out. Also, I imagine that there might be a better way of doing this, but this is my first complete set of Ruby/Watir scripts so bear with me if the setup seems inefficient or incorrect in some way. (All feedback appreciated.)
Background:- I have 4 Performance scripts that walk through the site maps for 4 different apps.- Each script is currently independent and does the following things:(a) opens up two files for writing output: one for the performance measurements, and one for a separate progress/status report (used for troubleshooting in case something goes wrong).
(b) walks through each page in the site map and records the (i) page size and (ii) download time.(c) closes the two files and the web browser.- These scripts all work as expected when run individually.
FIRST PROBLEM (with hack workaround):
- The last step above (c) was interesting, because it took me a while to figure out how to close the files as the *last* step in the test run.- To do this, I put all of the setup and tests into the first class (
e.g. class TC_BD01) and the 'close open files' step into a second class (e.g. class TC_BD02). I couldn't figure out any other way to ensure that this was performed in the correct order. On the downside, I have an extra unwanted Class with an unwanted TestCase that all it does is close some files and close the web browser.
- As an example, here is the output of the test file that helped me work out this line/class/test order problem (the general structure is the same as my real script, except all the code has just been replaced with a simple 'puts' line):
-ruby BD_site_map_tests.rb** TC_BD01_site_map_walkthru **Loaded suite BD_site_map_testsStarted] TC_BD1  test_a_Public_Pages]= TC_BD1 *teardown*.] TC_BD1  test_b_First_Time_login
]= TC_BD1 *teardown*.] TC_BD1  test_c_Main_Menu]= TC_BD1 *teardown*.] TC_BD2  test_wrap_up*-*-*-*-*-*-*-*-*-*.Finished in 0.0 seconds.4 tests, 0 assertions, 0 failures, 0 errors
Exit code: 0-= So it kind of bugs me that it reports 4 tests when really there are 3 tests and 1 'wrap_up' routine, but I can live with that (for now) because it works. In the long term I'd like to figure out how to solve this problem with the extra empty test cases.
SECOND PROBLEM (working with the new integrated script suite):- I stripped out all the constant declarations and custom methods into separate files. (Thanks for the help with this Bret and Sean G.)
- I created a master script file that has all the 'require' and 'include' statements and then calls the individual scripts one at a time.
= What I've noticed is that Ruby (1) scans through *all* of the scripts, (2) groups all of the [non test case lines] and [test cases] and then (3) runs them in that group order. I think it's really whacked, but that's what I've seen.
- Here's my Script_Order_TestSuite.rb file:-require 'common'# The Tests:puts '-= Wrapper A - BEFORE =-' require 'BD_shell_tests'puts '-= Wrapper A - AFTER =-'puts ''puts '-= Wrapper B - BEFORE =-'
 require 'SD_shell_tests'puts '-= Wrapper B - AFTER =-'puts ''# End-And here's the output:-ruby Script_Order_TestSuite.rb-= Wrapper A - BEFORE =-** TC_BD01_site_map_walkthru **
-= Wrapper A - AFTER =--= Wrapper B - BEFORE =-** TC_SD01_site_map_walkthru **-= Wrapper B - AFTER =-Loaded suite Script_Order_TestSuiteStarted] TC_BD1  test_a_Public_Pages]= TC_BD1 *teardown*
.] TC_BD1  test_b_First_Time_login]= TC_BD1 *teardown*.] TC_BD1  test_c_Main_Menu]= TC_BD1 *teardown*.] TC_BD2  test_wrap_up*-*-*-*-*-*-*-*-*-*.] TC_SD1  test_a_Public_Pages
]= TC_SD1 *teardown*.] TC_SD1  test_b_First_Time_login]= TC_SD1 *teardown*.] TC_SD1  test_c_Main_Menu]= TC_SD1 *teardown*.] TC_SD1  test_d_Admin_Pages]= TC_SD1 *teardown*
.] TC_SD2  test_wrap_up*-*-*-*-*-*-*-*-*-*.Finished in 0.0 seconds.9 tests, 0 assertions, 0 failures, 0 errorsExit code: 0-= What I was *expecting* was that the master script would do the Wrapper # - Before stuff *prior* to running the test cases in the called script, and *then* perform the Wrapper # - After stuff when that called script was complete. But that's not what happens.
MY QUESTION(S):- Given : Ruby will always pool *all* the TestCases together and run them as a set/suite in ascending order by class and then by TestCase. So I need to rethink how the output files are opened and closed, as well as how the browsers are opened and closed.
Does anyone have any suggestions as to how I can properly close open files after each test script/suite run? (The reason I did this in each script was so that I 

  1   2   >