Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Unable to open the script in anouther script

Reply
Thread Tools

Unable to open the script in anouther script

 
 
Pranjal Jain
Guest
Posts: n/a
 
      04-09-2008
Hi All
I ma trying to call the function written in one script in other script.
But it is giving me the error.

The called script is 2.rb

require 'watir'
def test_b

$ie1 = IE.new

$ie1.text_field(:name, "q").set "pickaxe"
$ie1.button(:name, "btnG").click
#ie.showAllObjects
end

the calling script is 1.rb

require 'watir'
require '2'

class TestCase

def test_a
$ie = IE.new
$ie.goto 'www.google.com'
end
test_b
end


The error popped is as follows:

/2.rb:4: in 'test_b': uninitialized constant IE(NameError)
from 1.rb:10

Please help.
Thanks in advance.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Stefan Lang
Guest
Posts: n/a
 
      04-09-2008
2008/4/9, Pranjal Jain <(E-Mail Removed)>:
> Hi All
> I ma trying to call the function written in one script in other script.
> But it is giving me the error.
>
> The called script is 2.rb
>
> require 'watir'
> def test_b
>
> $ie1 = IE.new
>
> $ie1.text_field(:name, "q").set "pickaxe"
> $ie1.button(:name, "btnG").click
> #ie.showAllObjects
> end
>
> the calling script is 1.rb
>
> require 'watir'
> require '2'
>
> class TestCase
>
> def test_a
> $ie = IE.new
> $ie.goto 'www.google.com'
> end
> test_b
> end
>
>
> The error popped is as follows:
>
> ./2.rb:4: in 'test_b': uninitialized constant IE(NameError)
> from 1.rb:10


I've never used Watir myself, but looking at the API docs it
looks like you should replace references to IE with
Watir::IE.

HTH,
Stefan

 
Reply With Quote
 
 
 
 
Chris Hulan
Guest
Posts: n/a
 
      04-09-2008
On Apr 9, 3:03 am, Pranjal Jain <(E-Mail Removed)> wrote:
> Hi All
> I ma trying to call the function written in one script in other script.
> But it is giving me the error.
>
> The called script is 2.rb
>
> require 'watir'
> def test_b
>
> $ie1 = IE.new
>
> $ie1.text_field(:name, "q").set "pickaxe"
> $ie1.button(:name, "btnG").click
> #ie.showAllObjects
> end
>
> the calling script is 1.rb
>
> require 'watir'
> require '2'
>
> class TestCase
>
> def test_a
> $ie = IE.new
> $ie.goto 'www.google.com'
> end
> test_b
> end
>
> The error popped is as follows:
>
> /2.rb:4: in 'test_b': uninitialized constant IE(NameError)
> from 1.rb:10
>
> Please help.
> Thanks in advance.
> --
> Posted viahttp://www.ruby-forum.com/.


Remember that ruby is interpreted, and code is evaluated line by line

> class TestCase
> def test_a
> $ie = IE.new
> $ie.goto 'www.google.com'
> end

test_a is defined but has NOT been executed
> test_b

test_ is invoked here, the code is executed
Since test_a has not been executed yet $ie has not been defined
> end



I'd suggest:
class TestCase
def test_a
$ie = IE.new
$ie.goto 'www.google.com'
test_b
end
end
 
Reply With Quote
 
Julian Leviston
Guest
Posts: n/a
 
      04-09-2008
[Note: parts of this message were removed to make it a legal post.]

Ruby is complaining that there's an uninitialized constant called
IE... which means (funnily enough) that it doesn't know what IE means.

This is probably because you're trying to use a constant which is
namespaced without the namespace!

also, I think that you probably used to use php, given the
nomenclature you're using, and the fact that you're putting $ chars in
front of all your variable names.

Don't do this. $ in front of a variable name means it's a global, and
I'm fairly sure you don't want globals all through your code.

This is what you probably wanted: (from the watir example page)

ie = Watir::IE.new

Julian.



Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)
VIDEO #3 out NOW!
http://sensei.zenunit.com/


On 09/04/2008, at 5:03 PM, Pranjal Jain wrote:

> Hi All
> I ma trying to call the function written in one script in other
> script.
> But it is giving me the error.
>
> The called script is 2.rb
>
> require 'watir'
> def test_b
>
> $ie1 = IE.new
>
> $ie1.text_field(:name, "q").set "pickaxe"
> $ie1.button(:name, "btnG").click
> #ie.showAllObjects
> end
>
> the calling script is 1.rb
>
> require 'watir'
> require '2'
>
> class TestCase
>
> def test_a
> $ie = IE.new
> $ie.goto 'www.google.com'
> end
> test_b
> end
>
>
> The error popped is as follows:
>
> ./2.rb:4: in 'test_b': uninitialized constant IE(NameError)
> from 1.rb:10
>
> Please help.
> Thanks in advance.
> --
> Posted via http://www.ruby-forum.com/.
>





 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: how to open a file in some application using Tkinter i am usingTKINTER to create GUI application i want to know how to open a worddocument in open office or any other applicatio Fredrik Lundh Python 1 01-09-2008 10:40 AM
Superimposing one image on anouther ampeloso@gmail.com Javascript 1 04-08-2007 04:47 PM
Anouther HJT Log Cooter Computer Support 4 11-19-2005 10:03 PM
Unable to see machines on the ethernet; Unable to find printers =?Utf-8?B?Sm9obiBN?= Wireless Networking 1 06-07-2005 03:32 AM
Going from one VCD disk to anouther in my: Phillips DVD755VR DVD player and VHS recorder combi. Mick. Computer Support 0 02-13-2005 10:55 AM



Advertisments