Extending Watir::Checkbox class

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’

.
.
.

ie.checkboxes.each {|cb|
cb.test(“jfkdsajf”, “jfkdlas”, “jfkdlasjf”)
}

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

What am I doing wrong here?

Patrick S. wrote:

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

What am I doing wrong here?

Anyone?

What am I doing wrong here?

Anyone?

Could you please explain what you are trying to do?

Bret P. wrote:

What am I doing wrong here?

Anyone?

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

Patrick S. wrote:

I googled “extending watir” and found this…
http://wiki.openqa.org/pages/viewpage.action?pageId=1119

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs