[Wtr-general] Is there a method to do ie.contains_html() ?
hopper
hopper at interlog.com
Wed Oct 26 22:29:58 EDT 2005
thank for metioning that Jeff, I forget that the assert functions are
part of TestCase.
an interesting read for that is:
http://wiki.rubyonrails.com/rails/pages/HowtoUnitTest
and it states
-------------------quote--------------
The Hierarchy
There's a hierarchy involved with unit tests. It starts at an individual
assertion (more later), and ends at a suite (more later).
Bottom up, it looks like this:
* *assertion* belongs to a
o *test* which belongs to a
+ *test case* which belongs to a
# *test suite*
--------------------end quote------------------------
Jeff Wood wrote:
> There are two problems ... #1 you can't use the assert functions
> unless you are building a TestCase object...
>
> #2 you don't need the search_html function.
>
> just
>
> require 'watir'
> include Watir
>
> class Watir::IE
> def contains_html( input )
> html.scan( input ) != []
> end
> end
>
> $ie = IE.new
> $ie.goto http://example.com
> $ie.contains_html( "." )
>
> should return a true or false. so you could do
>
> if $ie.contains_html "."
> puts "Has html"
> else
> puts "Doesn't have html"
> end
>
> ... that's all there is to it... My code was meant as an alternative ...
>
> but any function that people send to you that contains assert won't
> work without additional libraries being required.
>
> Let me know if my example doesn't work for you.
>
> j.
>
>
> On 10/26/05, *Sy Ali* <sy1234 at gmail.com <mailto:sy1234 at gmail.com>> wrote:
>
> Jeff, does that mean that I do this? :
>
> require 'Watir' # the watir controller
> include Watir
>
> class Watir::IE
> def search_html( input )
> html.scan( input ) != []
> end
> end
> def search_html(string)
> puts " searching the source for " + string
> begin
> assert_match($ie.contains_html,string)
> puts " ok -- found " + string
> rescue => e
> puts ">>>FAIL -- could not find " + string
> end
> end
>
> $ie = Watir::IE.start(" http://example.com")
> search_html(".")
>
>
> Because this also fails..
>
> _______________________________________________
> Wtr-general mailing list
> Wtr-general at rubyforge.org <mailto:Wtr-general at rubyforge.org>
> http://rubyforge.org/mailman/listinfo/wtr-general
>
>
>
>
> --
> " http://ruby-lang.org -- do you ruby?"
>
> Jeff Wood
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Wtr-general mailing list
>Wtr-general at rubyforge.org
>http://rubyforge.org/mailman/listinfo/wtr-general
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20051026/2b423b3d/attachment.html
More information about the Wtr-general
mailing list