I think you want to use an instance variable. Thus "@browser" instead of 
"browser".

You also need to read the docs on the newest version of Rspec, which 
needs an additional "require" if you want to run your scripts using "ruby".

Or you can use WatirCraft, which handles both of these issues for you.


Bret

«°¤§ømåtïçCðrp§ë¤°» wrote:
> So, I'm trying to do some BDD/TDD development, and I can't figure some
> things out...
>
> Primarily, if I run the script, using "ruby T.rb", nothing happens -
> nothing returns, etc. If I use "spec T.rb", then I get a bunch of
> errors.
>
> Does ruby/watir/spec treat each instance (describe/do) as it's own
> main, leaving the objects within that section?
>
> I'll append the code, to illustrate what I'm doing, and the errors,
> afterwards...
>
> [code]
>
> ##--------------------------------------------------------------------------------------------------------------------
> ##
> ##                                                                            
>                                         ##
> ##Sevin V 0.0.1                                                               
>                                         ##
> ##Sevin is written by Bailey, John E.                                         
>                                 ##
> ##Sevin is written under the GPL/GNU.                                         
>                                 ##
> ##                                                                            
>                                         ##
> ##                                      ErrorCodes ::
> ErrorCodes                                                            ##
> ##Code1 - User Initiated Error (Some instance that is directly related
> to user action/inaction)              ##
> ##Code2 - System Initiated Error (Some instance that is directly
> related to system action/inaction)    ##
> ##                                                                            
>                                         ##
> ##                                                                            
>                                         ##
> ##--------------------------------------------------------------------------------------------------------------------
> ##
>
>   #################
>  #Process Dependencies        #
> #################
> require 'spec'
> require 'watir'
> require 'test/unit'
>
>     ##########################
>    #                                                        #
>   #                  Begin Iteration                    #
>  #                                                            #
> ##########################
>
> #####################
> #Get Customer Info                    #
> ####################
> Fname = String.new
> LName = String.new
>
> puts "What is the user's First Name?"
> Fname = gets.chomp #Removes return (recognized as new line command)
> character '\n'
> puts "What is the user's Last Name?"
> Lname = gets.chomp #Removes return (recognized as new line command)
> character '\n'
>
> #####################
> #Take control of the Brower        #
> ####################
>       describe "Ticket Processing" do
>               it "should click the button to begin the process" do
>                       begin
>                       #attach to a running instance of IE
>                       browser = Watir::IE.attach(:url, 'https://
> www.servicecenterweb.unisys.com/sc2/index.do')
>                               #rescue the process, if no instance is running
>                               rescue 
> Watir::Exception::NoMatchingWindowFoundException
>                                       puts "ALERT: You must have a running 
> instance of SVC open!"
>                                       browser = Watir::IE.new(:url, 'https://
> www.servicenterweb.unisys.com/sc2/index.do')
>                                       puts "Please log into SVC and restart 
> Sevin. Exiting: Code1."
>                               break
>                       end
>                       #sets speed of browser/process handling
>                       browser.speed = :zippy
>                       #take control and begin creating a new ticket
>                       browser.frame(:id, 'detail').button(:id, 'X8').click
>               end
>       end
> ######################
> #Validate IE returned correct page #
> #####################
>       describe "vaildating text on the page" do
>               it "should find predefine text on a page" do
>                       #validate that the process worked
>                       if ibrowser.text.include?("COMPANY INFORMATION")
>                                       puts: "Validated returned page - Sevin 
> Continuing."
>                               else
>                                       puts: "Sevin Failed! Exiting: Code2. 
> Page didn't contain text:
> COMPANY INFORMATION."
>                                       break
>                       end
>               end
>       end
> ######################
> #Begin Entitlement processing        #
> #####################
>       describe "Entitlment processing" do
>               it "should insert the user's name and company" do
>                       #Insert company name and user
>                       broswer.frame(:id, 'detail').text_field(:id, 
> 'X6').set("BAXTER")
>                       browser.frame(:id, 'detail').text_field(:id, '  
> ').set(%Fname)
>                       broswer.frame(:id, 'detail').text_field(:id, '  
> ').set(%Lname)
>                       browser.frame(:id, 'detail').button(:id, '  ').click
>               end
>       end
> ######################
> #Ensure entitlement was successful #
> #####################
>       describe "Validate text on page (phone)" do
>               it "should fine some data filled into form" do
>                       #Validate data is in phone field
>
>               end
>       end
> ######################
> #Begin Ticket Creation                  #
> #####################
>       describe "Begin creating the ticket" do
>               it "should place data into the required fields" do
>                       #Insert data
>
>               end
>       end
>
>
> #TODO: implement remaining code, after admin privileges are granted.
> [/code]
>
>
> ERRORS:
> C:\Documents and Settings\M0nKy\Desktop>spec T.rb
> What is the user's First Name?
> What is the user's Last Name?
> .ALERT: You must have a running instance of SVC open!
> Please log into SVC and restart Sevin. Exiting: Code1.
> FFF..
>
> 1)
> NoMethodError in 'Ticket Processing should click the button to begin
> the process
> '
> undefined method `speed=' for nil:NilClass
> ./T.rb:55:
>
> 2)
> NameError in 'vaildating text on the page should find predefine text
> on a page'
> undefined local variable or method `browser' for
> #<Spec::Example::ExampleGroup::
> Subclass_3:0x32e7acc>
> ./T.rb:67:
>
> 3)
> NameError in 'Entitlment processing should insert the user's name and
> company'
> undefined local variable or method `browser' for
> #<Spec::Example::ExampleGroup::
> Subclass_4:0x32e4b88>
> ./T.rb:81:
>
> Finished in 12.578 seconds
>
> 6 examples, 3 failures
>
> C:\Documents and Settings\M0nKy\Desktop>
>
> C:\Documents and Settings\M0nKy\Desktop>ruby T.rb
>
> C:\Documents and Settings\M0nKy\Desktop>
>
>
>
> >
>   


-- 
Bret Pettichord
CTO, WatirCraft LLC, www.watircraft.com
Lead Developer, Watir, www.watir.com
Blog, www.io.com/~wazmo/blog
Twitter, www.twitter.com/bpettichord

Watir Training: Portland/Beaverton April 16-17
www.watircraft.com/training


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---

Reply via email to