[Wtr-general] Application Map
Bret Pettichord
bret at pettichord.com
Thu Apr 20 13:18:20 EDT 2006
I am thinking of adding a Map class to Watir. Here's how it would work...
On 4/20/06, Adrian Rutter <Adrian.Rutter at tnt.com> wrote:
>
> Hi,
>
> If we take a look at the 'googlesearch' example. we have two actions that
> are sent to different objects
>
> ie.text_field(:name, "q").set("pickaxe") # q is the name of the
> search field
> ie.button(:name, "btnG").click # "btnG" is the name of the Search button
>
>
> I think what we'd have to map is this:
>
> text_field(:name, "q")
>
> so
>
> SearchField="text_field(:name, 'q')"
map = Watir::Map.new
SearchField=map.text_field(:name, 'q')
Now.I was thinking of using the Ruby HashMap, so we could have
>
> googlewin = {
> "SearchField" => "text_field(:name, 'q')"
> "SearchButon" => "button(:name, 'btnG')"
>
> ... etc
>
> }
SearchButton = map.button(:name, 'btnG')
> We will need to keep all action methods in a collection as well (e.g.
> click, set)
>
> So the test table will look something like this
>
> test, win object Action Arg #header
>
> T, googlewin, SearchField, set, "PickAxe"
> T, googlewin, SearchButon, click
>
> We could read in and process the above input, so the script will look like
>
> GUIAction = "ie." + object + "." + Action "." + Args
To use these objects you would first do
ie = Watir::IE.start('http://google.com')
map.bind(ie)
SearchField.set("PickAxe")
SearchButton.click
Questions
>
> 1. What do you think?
> 2. Should I put every GUIobject within 1 class with every window being a
> different method or each window being a separate class?
If you wanted to, you could store these map-elements in a module named after
the window:
GoogleWin::SearchButton = map.button(:name, 'btnG')
3. I am not so sure on the Ruby syntax to get the value from a key? Is it
> something like ' googlewin.key("SearchField")' ?
>
> Aidy
>
>
>
>
> ---------------------------------------------------------------------------------------------------------------
> This message and any attachment are confidential and may be privileged or
> otherwise protected from disclosure.
> If you are not the intended recipient, please telephone or email the
> sender and delete this message and any attachment from your system.
> If you are not the intended recipient you must not copy this message or
> attachment or disclose the contents to any other person.
>
> ---------------------------------------------------------------------------------------------------------------
> _______________________________________________
> 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/20060420/7db4c456/attachment.html
More information about the Wtr-general
mailing list