Extending Watir::Checkbox class

P

Patrick Spence

I have a script which contains class extensions. The Checkbox.test() is
obviously just a stub right now, but I'm trying to get my head around
the concept.

#-- contained in classExtensions.rb
module Watir

class Checkbox < Watir::RadioCheckCommon

def test(property, expectedResult)
puts("Checkbox.test()")
end

end

end

In another script, I have the following...

require 'watir'
require 'sqlClient'
require 'classExtensions'
 
P

Patrick Spence

Patrick Spence wrote:
However, I'm getting the following error:
#<NoMethodError: private method `test' called for #<Watir::CheckBox>>

What am I doing wrong here?

Anyone?
 
P

Patrick Spence

Bret said:
Could you please explain what you are trying to do?

I googled "extending watir" and found this...
http://wiki.openqa.org/pages/viewpage.action?pageId=1119, which got me
pointed in the right direction. Here's the definition of the class
extension, although I must admit I don't fully understand it. At any
rate, when I run the test script, "test" is now listed as *public*
method.

class Watir::CheckBox

def test(property, expectedResult)
puts("CheckBox.test(\"#{property}\", \"#{expectedResult}\")")
end

end

Bret, in response to your query... I'm having to modify the way we are
checking properties on web page controls; visible, enabled, disabled...
blahblah, in order to "conform" to a new way my supervisor wants tests
run. When I started on this project, I was looking at the forms and
running the tests on each form as a whole. We are now breaking the forms
down to their individual components and testing each one, comparing the
expected test results, contained in a SQL Server table, with the actual
result. I only wish someone had thought about that 3-months ago,
probably should've been me actually. Most of the work already done by
myself and a coworker will have to be re-written to conform to the new
testing "model". Oh well... it beats standing in a line!

--Patrick
 
P

Patrick Spence

Patrick Spence wrote:
<snip>
Sorry 'bout the password protected site, I'd forgotten about that.
Anyway, I found the following code posted:

class Watir::Element

# If any parent element isn't visible then we cannot write to the
# element. The only realiable way to determine this is to iterate
# up the DOM element tree checking every element to make sure it's
# visible.
def visible?
# Now iterate up the DOM element tree and return false if any
# parent element isn't visible or is disabled.
object = document
while object
begin
if object.style.invoke('visibility') =~ /^hidden$/i
return false
end
if object.style.invoke('display') =~ /^none$/i
return false
end
if object.invoke('isDisabled')
return false
end
rescue WIN32OLERuntimeError
end
object = object.parentElement
end
true
end
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top