The following watir code is enough to demonstrate the flaw in the
row_count method.
The table has 2 rows - but watir return 6.
The problem is tables embedded in tables and the rowcount simply
counting TR tags from the outside. Therefore it counts inner table
rows as well
Code can then fail
This is not the only routine and while digging I found comments like
# This method returns the table as a 2 dimensional array. Dont expect
too much if there are nested tables, colspan etc.
All the routines seem to use the following process
rows = table object.getElementsByTagName(TR).length
Overloading the following seems to get past the limitations. Perhaps
someone with more DOM experience can comment if there are any dangers
One thin I did notice is that it picks up TH data cells just like
TD ones
class Table
def row_count
assert_exists
return
Just to update here is a version of my final routine
Hope it helps someone else
Paul
--
def JavaScript(zone,on=nil,silent=nil)
# if on is nil it returns true iff javascript is enabled (not it
could also be off or prompt, both false)
# if true it sets it to enabled
# if false it
Someone unfortunately upgraded one of my PC's. I was pleased to find
miost watir scripts still ran. One did not. It was the only one that
utilized two IE windows at the same time. The code below demonstrates
the issue - it should open two IE windows and print DONE.
It does open the browsers
I had problems with the following html
labelUsername/label
input type=text name=AJ8765 /
ie.text_field(:afterText,'Username').set(XXX) # fails
It seems the label tags cause a problem - likewise if they are any
other tags span div etc
Is this expected behaviour?
Paul
In previous versions of watir I used to send 11 characters to a field
that had a maxlimit of 10. This would ensure the server also checked
the parameter and did something sensible (truncate or error message).
The newer version seems a bit safer and ie.text_field (:index,1).set
(01234567890)
I must be missing something but I spent some time yesterday trying to
get the page status code. But I could not find this anywhere.
I want to know if the page I requested failed in some way(404,500),
was from the cache(302), or was successfully fetched(200).
How do I get the page status? Or
In watir.rb there are several class additions to add a matches
function that is similar in each type (see below).
Wouldn't it be a little more consistent if they all returned the same
data types.
Regexp.matches returns MatchData or nil
The others return true or false
class String
def
I finally found a performance issue and it was in the watir library.
If a page (and dont get me started about it) has 200 plus radio
buttons and your watir script decides to print all the attributes like
so
radios = ie.radios()
for radio in radios
puts radio.name
puts radio.value
end
Then
Thanks for all the replys.
At first I was quite excited then realized they would make additional
calls - the cookies, session, conversation elements would all be a
nightmare. Not to mention that the load balancer may give valid
results sometimes and invalid the next (say if one server is bad).
So you can build a function that takes in both an Integer, String, or
Regex and then matchs it without having to build a case or switch
if (parameter.matches(value))
note parameter could be any of the three types and the correct match
function will apply.
Found a solution
ie.text_field(itemtype,itemname).value=text
works just fine.
Also use the same technique to select options (choice) in a combo
where that value may not already exist
s = ie.select_list(itemtype,itemname)
texts = s.getAllContents
if (texts==[])
I installed up a new machine with ruby, watir, and selenium-webdriver and
the script (that still runs on the previous version) now will not start
I produced a minimal script below and the reported error (with version
numbers visible in the dump)
Is there a workaround to get the new machine
I'd like to suggest a minor update to Watir::Element#flash
I have added three parameters to remove the hard coded values only. I gave
them defaults so if not provided the function is backwards compatible.
But this allows the external caller to choose what color they want to flash
the element
The solution below assumes the input fields should eb treated as input
elements and uses the sendkeys, I always add the hash brackest - I just
find it easier to as other attributes later.
The browser new command has a few usefull switches to maximize the browser
by removing user features
This should work
@browser.driver.window.maximize
@browser.driver.window.resize_to(900,900)
--
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
watir-general@googlegroups.com
http://groups.google.com/group/watir-general
17 matches
Mail list logo