Re: [Wtr-general] Watir tests as how-to documents
At the end I decided to use Watir only. I took a closer look at application that I test and found out that there are labels for elements. UsernameI added this to the end of Watir::TextField#setwhat = @container.label(:for, @what).text puts "- at text field '#{what}' enter '[#{what}]'"and got - at text field 'Username' enter '[Username]'That is all I need. I added something similar to other methods. I have two questions. 1) Should I use @container or some other variable? It works.2) How should I extract this? I do not want to modify watir.rb, because I would have to modify it every time I upgrade. At the moment I created new file howto.rb (at the end of e-mail). I require this file in my scripts. This is the only way I knew how to override Watir's methods. Is there a better way?Thanks,Zeljko-- http://zeljkofilipin.com/#howto.rbmodule Watir class TextField < InputElement def set(setThis) assert_enabled assert_not_readonly highlight(:set) @o.scrollIntoView @o.focus @o.select @o.fireEvent("onSelect") @o.value = "" @o.fireEvent("onKeyPress") doKeyPress(setThis) highlight(:clear) @o.fireEvent("onChange") @o.fireEvent("onBlur") what = @container.label(:for, @what).text $howto.puts "+at text field '#{what}' enter '[#{what}]'" end endend ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Watir tests as how-to documents
Thank you all. I will take a look at tools that you suggested.Zeljko-- http://zeljkofilipin.com/ ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Watir tests as how-to documents
rspec gets closest to doing this. THere is some command line option that you need to use. But I cant rememerb what it is You have a bunch of Watir tests, right? With every build of your application under test, you run them all. If a test fails, application should be fixed, or you test should be fixed. Wouldn't it be nice to make how-to documents from that tests? Time for an example.def login_as(username, password) ie.goto("my.app/login") ie.should_contain("please login") ie.text_field(:id, "username").set(username) ie.text_field(:id, "password").set(password) ie.button(:value, "login").click ie.should_contain("logged in as #{username}")endYou run that test, and you get output like this:How to login?- go to page my.app/login - there should be text "please login"- enter username at username text field- enter password at password text field- click button login- there should be text "logged in as username" Has anybody done something like this? I am thinking of doing it, but If somebody has done it already, I would like to take a look.Zeljko -- http://zeljkofilipin.com/ ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Watir tests as how-to documents
Željko Filipin wrote: > Has anybody done something like this? I am thinking of doing it, but > If somebody has done it already, I would like to take a look. Systir included something along these lines. You should check it out. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Watir tests as how-to documents
I do this to a degree, but I consider it to be logging not documentation. I have 3 levels of logging (there are more, but thats besides the point) Section, Test and Details A section would be like "Administration" a test would "Create a New User" and details are "Clicked 'new user', 'Set user name 'Sam' '. When my program runs the output is in excel, and the different types are color coded. The 'details' are normally filtered out, its way too much information. [11:30am] - Administration (this is yellow background) [11:30am] - click new user (this is grey background) [11:30am] - set user name 'sam' (this is grey background) [11:31am] - Login PASS (or if something went wrong, login FAIL, or if it exploded UNKNOWN ERROR) (this is white background) Personally I do not want to generate a test document from my script. My script should be born from a document. Thats me though, it all depends on the situation. - Posted via Jive Forums http://forums.openqa.org/thread.jspa?threadID=5156&messageID=14301#14301 ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Watir tests as how-to documents
Check out Joe O'Brien's recent rSpec post: http://objo.com/2006/11/7/rspec-7-is-outThat might get you part of the way. -Chris On 11/8/06, Željko Filipin <[EMAIL PROTECTED]> wrote: You have a bunch of Watir tests, right? With every build of your application under test, you run them all. If a test fails, application should be fixed, or you test should be fixed. Wouldn't it be nice to make how-to documents from that tests? Time for an example.def login_as(username, password) ie.goto("my.app/login") ie.should_contain("please login") ie.text_field(:id, "username").set(username) ie.text_field(:id, "password").set(password) ie.button(:value, "login").click ie.should_contain("logged in as #{username}")endYou run that test, and you get output like this:How to login?- go to page my.app/login - there should be text "please login"- enter username at username text field- enter password at password text field- click button login- there should be text "logged in as username" Has anybody done something like this? I am thinking of doing it, but If somebody has done it already, I would like to take a look.Zeljko -- http://zeljkofilipin.com/ ___Wtr-general mailing listWtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Watir tests as how-to documents
What I want to do is to generate how-to documents for users of application that I test. When user clicks how-to link (or help, or whatever), there should be list:- login- do something- do something else ...- logoutSelect login and you get:- go to 'my.app/login.aspx'- there should be text 'Please Login'- at text field Username enter your username- at text field Password enter your password - click button Login- url should be 'my.app/default.aspx'- there should be text 'logged in as [your username]'Zeljko-- http://zeljkofilipin.com/ ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
Re: [Wtr-general] Watir tests as how-to documents
On 11/8/06, Željko Filipin <[EMAIL PROTECTED]> wrote: > You have a bunch of Watir tests, right? With every build of your application > under test, you run them all. If a test fails, application should be fixed, > or you test should be fixed. Wouldn't it be nice to make how-to documents > from that tests? I am assuming that you are doing this not for the purpose of explaining what the tests do (anyone who can't understand cleanly written WATIR doesn't need the tests explained to them). But you are talking about reverse storyboarding here right? Its got potential alright, especially if you could automatically annotate reports in such a fashion. It would be especially useful if you could extract context from a fail this way (parsing log messages). You might never get a perfect solution, but it could be reasonably deterministic for a respectable amount of non-trivial tests. Useful for training too. ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
[Wtr-general] Watir tests as how-to documents
You have a bunch of Watir tests, right? With every build of your application under test, you run them all. If a test fails, application should be fixed, or you test should be fixed. Wouldn't it be nice to make how-to documents from that tests? Time for an example.def login_as(username, password) ie.goto("my.app/login") ie.should_contain("please login") ie.text_field(:id, "username").set(username) ie.text_field(:id, "password").set(password) ie.button(:value, "login").click ie.should_contain("logged in as #{username}")endYou run that test, and you get output like this:How to login?- go to page my.app/login - there should be text "please login"- enter username at username text field- enter password at password text field- click button login- there should be text "logged in as username" Has anybody done something like this? I am thinking of doing it, but If somebody has done it already, I would like to take a look.Zeljko -- http://zeljkofilipin.com/ ___ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general