The previous responder was right, it's important to understand how things are 
scoped. But you can use a global while you are looking into that. Just replace 
'@' with  '$'.

$browser = Watir::Browser.new:chrome 





________________________________
 From: Sohail Mirza <[email protected]>
To: [email protected] 
Sent: Tuesday, March 26, 2013 8:01 AM
Subject: Re: [wtr-general] how to call script within script
 

i have one common script Browser.rb which is used to initialize and open my web 
application in chrome browser. i called it once in my main script 
(AddCustomer.rb) and it opens browser and go to required url. In my Browser.rb 
script i initialized as follow 


  def setup
    @browser = Watir::Browser.new:chrome 
    @browser.goto ("http://testserver:8080/";)  #The URL should come from the 
excel file.
    @browser.window.maximize

  end

The problem is that variable @browser does not work for other scripts which i 
am calling in my main script (AddCustomer.rb) and hence object are 
identifiable. how can i resolve this issue?
Please advise.



On Tue, Mar 26, 2013 at 6:03 PM, Oscar Rieken <[email protected]> wrote:

I would also suggest picking up the ruby pickaxe book
>http://pragprog.com/book/ruby4/programming-ruby-1-9-2-0
>
>
>http://mislav.uniqpath.com/poignant-guide/
>
>
>
> and actually learning ruby here are a few places that may help as well
>http://tryruby.org/levels/1/challenges/0(free)
>
>
>http://www.codeschool.com/
>
>http://www.codecademy.com/ (free)
>
>
>
>
>
>
>
>
>On Tue, Mar 26, 2013 at 9:37 AM, Željko Filipin <[email protected]> 
>wrote:
>
>On Tue, Mar 26, 2013 at 2:32 PM, Sohail Mirza <[email protected]> wrote:
>>
>>i meant how can i call a script into another script.
>>"require" is what you are looking for:
>>
>>
>>http://rubylearning.com/satishtalim/including_other_files_in_ruby.html
>>
>>
>>Željko
>> -- 
>>-- 
>>Before posting, please read http://watir.com/support. In short: search before 
>>you ask, be nice.
>> 
>>[email protected]
>>http://groups.google.com/group/watir-general
>>[email protected]
>> 
>>--- 
>>You received this message because you are subscribed to the Google Groups 
>>"Watir General" group.
>>To unsubscribe from this group and stop receiving emails from it, send an 
>>email to [email protected].
>>For more options, visit https://groups.google.com/groups/opt_out.
>> 
>> 
>>
>
-- 
>-- 
>Before posting, please read http://watir.com/support. In short: search before 
>you ask, be nice.
> 
>[email protected]
>http://groups.google.com/group/watir-general
>[email protected]
> 
>--- 
>You received this message because you are subscribed to the Google Groups 
>"Watir General" group.
>To unsubscribe from this group and stop receiving emails from it, send an 
>email to [email protected].
>For more options, visit https://groups.google.com/groups/opt_out.
> 
> 
>

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.
 
[email protected]
http://groups.google.com/group/watir-general
[email protected]
 
--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

[email protected]
http://groups.google.com/group/watir-general
[email protected]

--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to