the idea is that each page in the app that Im testing has a corresponding class
n my test code.
the class would look something like this:
class MyLoginPage < SomeParentClass
text_field :user_name , :id=>'username'
text_field :pass_word, :id =>'password'
button :login_button , :value => 'Login Now'
title "Welcome To MyApp"
url /login.jsp/
def has_loaded
raise "Not loaded" unless user_name.exists?
end
def do( un , pw )
user_name.set( un )
pass_word.set( pw )
login_button.click
NextPage.has_loaded
end
end
the ParentClass would have methods to validate that everything is there, the
title is correct etc. It also has the code to do the translation of the
descrptive name ( eg login_button) to the actual element ( button(:value ,
'Login Now!')
I also have some code that generates this class from the page, so in irb you
would do something like this
ie.goto( 'http://server/login.jsp')
ie.gen => saves the class to a file using the title
which then saves the class above.
Bob Cotton from Rally has doe some similar type things, as has Elizabeth
Hendrickson. Another guy I have worked with also came up with something
similar, which makes me think this is sort of okay.
Ive also been using something like this for model based testing, which really
is kind of neat.
Paul
----- Original Message -----
From: aidy lewis <[EMAIL PROTECTED]>
Date: Tuesday, March 27, 2007 11:10 am
Subject: Re: [Wtr-general] little framework
> paul
> could you give us a little taster of your efforts?
> aidy
>
>
> On 27/03/07, Paul Rogers <[EMAIL PROTECTED]> wrote:
> >
> > Ive been working on some things that ( at least to my mind)
> simplify how the
> > code represents an html page. It also has several other
> advantages. I'll
> > probably publish it in a seperate library ( or via the contrib
> dir )
> >
> > as for your code, the firsat think i would do is get rid of the
> global ie.
> > even replacing it with a method is better
> >
> > $ie = Watir::IE.new
> >
> > def my_browser
> > $ie
> > end
> >
> > my_browser.goto('http://someurl')
> >
> >
> > at least this way its a bit easier to switch to firefox, or do
> something> different with the browser.
> >
> >
> > Paul
> >
> >
> > ----- Original Message -----
> > From: aidy lewis <[EMAIL PROTECTED]>
> > Date: Tuesday, March 27, 2007 9:56 am
> > Subject: [Wtr-general] little framework
> >
> > > Hi,
> > >
> > > Could anyone give me some feedback on this?
> > >
> > > Each HTML objects exists in a module
> > >
> > > <snip>
> > >
> > >
> > > module Field
> > >
> > > MAP_FIELD = Hash.new {|h,k| k}.update(
> > > 'username' => 'login', # gui name => HTML name
> > > 'password' => 'password'
> > > )
> > >
> > > def Field.set(name,args)
> > > $ie.text_field(:name, MAP_FIELD[name]).set(args)
> > > end
> > >
> > > def Field.assert(name,args)
> > > puts $ie.text_field(:name,
> MAP_FIELD[name]).verify_contains(args)> > end
> > > end
> > >
> > > <snip>
> > >
> > > At the top of each module is a hash map that acts as an object
> map for
> > > each object.The gui name is mapped to the object name
> > >
> > > <snip>
> > >
> > > MAP_BUTTON = Hash.new {|h| k}.update(
> > > 'login' => 'Login'
> > > )
> > >
> > > <snip>
> > >
> > > IE methods go here
> > >
> > > <snip>
> > >
> > > module Explorer
> > > def Explorer.start(url)
> > > $ie = IE.new
> > > @url=url
> > > $ie.goto(@url)
> > > end
> > >
> > > def Explorer.close
> > > $ie.close
> > > end
> > > end
> > >
> > > <snip>
> > >
> > > Each test will be in a class
> > >
> > > <snip>
> > >
> > > class TestClass
> > >
> > > def test_1
> > >
> > > Explorer.start 'http://aidy_server.com/'
> > > Field.set 'username', 'aidy'
> > > Field.assert 'username', 'aidy'
> > > Field.set 'password', 'password123'
> > > A_Button.press 'login'
> > > Explorer.close
> > >
> > > end
> > >
> > > end
> > >
> > > TestClass.new.test_1
> > > <snip>
> > >
> > > Not so sure about logging, but will probably write to XML
> > >
> > > Any opinions?
> > >
> > > aidy
> > > _______________________________________________
> > > Wtr-general mailing list
> > > [email protected]
> > > http://rubyforge.org/mailman/listinfo/wtr-general
> > >
> > _______________________________________________
> > Wtr-general mailing list
> > [email protected]
> > http://rubyforge.org/mailman/listinfo/wtr-general
> >
> _______________________________________________
> Wtr-general mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/wtr-general
>
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general