[wtr-general] Re: IE instance problem

2009-04-01 Thread Vikas Tulashyam

Hi Anna,
Is there any method by which I can convert the String values to Hash.

Thanks
Vikas


On Apr 1, 11:06 am, Anna Gabutero a...@lavabit.com wrote:
 On Tue, Mar 31, 2009 at 09:07:29PM -0700, Vikas Tulashyam wrote:

  Hi firends,
  Please help me.

  Thanks
  Vikas

  On Mar 31, 6:24 pm, Vikas Tulashyam vtulash...@gmail.com wrote:
   Hi,
   Actually, I am trying to read the sLocator value form a xml file and
   thats the main problem if I put the value directly into a variable
   then it's working fine like--

   a= {:name='q'}
   return $sBrowser.text_field(a)

   Code written above works fine but when I m doing this-

           sLoc = getObjectLocator(Text_Search)
           return $sBrowser.text_field(sLoc)

           def getObjectLocator(sObjectId)
           begin
             $sObjectFile = Document.new File.new(c:\\a.xml)

             $sObjectFile.elements.each(//TestObject[Identifier='#
   {sObjectId}']) { |element|
               sLocator = element.elements['Locator'].text
               sObjectType = element.elements['ObjType'].text
               return sLocator
             }

   sLoc returns the correct value, I tried this by printing the sLoc
   value but It is nt working

 It is returning a different value.  Your assignment is equivalent to:

   sLoc = {:name='q'}

 which is different from:

   a = {:name='q'}

 The first is a string, the second is a hash, and these object types are
 not interchangeable.

 - Anna
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[wtr-general] Re: IE instance problem

2009-04-01 Thread Anna Gabutero

P.S. Starting your variable names with $ turns them into global
variables.  Avoid doing so unless you really need it.

- Anna


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[wtr-general] Re: IE instance problem

2009-04-01 Thread Anna Gabutero

On Tue, Mar 31, 2009 at 11:33:42PM -0700, Vikas Tulashyam wrote:
 
 Hi Anna,
 Is there any method by which I can convert the String values to Hash.
 
 Thanks
 Vikas

Well, the fastest (but also dirtiest) way is instance_eval:

irb(main):001:0 s = {:name='q'}
= {:name='q'}
irb(main):002:0 s.class
= String
irb(main):003:0 o = instance_eval(s)
= {:name=q}
irb(main):004:0 o.class
= Hash

This would work, but I wouldn't recommend it since it interprets
everything in Locator as Ruby code.

You could also add more structure to the locator and build the hash
yourself:

Locator
Keyname/Key
Valueq/Value
Locator

def get_object_locator(object_id)
  object_file = Document.new File.new('c:\a.xml')
  object_file.elements.each(//TestObject[Identifier='#{object_id}']) {
locator = element.elements['Locator']
key = locator.elements['Key'].text
value = locator.elements['Value'].text
return { key.to_sym, value }
  }
end

That's not the most elegant of code, but you get the idea.


HTH,
Anna

 
 On Apr 1, 11:06 am, Anna Gabutero a...@lavabit.com wrote:
  On Tue, Mar 31, 2009 at 09:07:29PM -0700, Vikas Tulashyam wrote:
 
   Hi firends,
   Please help me.
 
   Thanks
   Vikas
 
   On Mar 31, 6:24 pm, Vikas Tulashyam vtulash...@gmail.com wrote:
Hi,
Actually, I am trying to read the sLocator value form a xml file and
thats the main problem if I put the value directly into a variable
then it's working fine like--
 
a= {:name='q'}
return $sBrowser.text_field(a)
 
Code written above works fine but when I m doing this-
 
        sLoc = getObjectLocator(Text_Search)
        return $sBrowser.text_field(sLoc)
 
        def getObjectLocator(sObjectId)
        begin
          $sObjectFile = Document.new File.new(c:\\a.xml)
 
          $sObjectFile.elements.each(//TestObject[Identifier='#
{sObjectId}']) { |element|
            sLocator = element.elements['Locator'].text
            sObjectType = element.elements['ObjType'].text
            return sLocator
          }
 
sLoc returns the correct value, I tried this by printing the sLoc
value but It is nt working
 
  It is returning a different value.  Your assignment is equivalent to:
 
    sLoc = {:name='q'}
 
  which is different from:
 
    a = {:name='q'}
 
  The first is a string, the second is a hash, and these object types are
  not interchangeable.
 
  - Anna
  
 
 
 Use the link below to report this message as spam.
 https://lavabit.com/apps/teacher?sig=533695key=3598775855
 


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[wtr-general] Re: IE instance problem

2009-04-01 Thread Vikas Tulashyam

Hi,
Thanks for the time. It returns hash values but I want to use this
value into methods for objects identification like-

a= get_object_locator(Text1)

ie.text_field(a).set(test)

Here, it's not working as it is.So how I can use this. I am very new
to Watir and don't have too much idea. Sorry to bother you guys again
and again.

Thanks
Vikas





On Apr 1, 12:24 pm, Anna Gabutero a...@lavabit.com wrote:
 P.S. Starting your variable names with $ turns them into global
 variables.  Avoid doing so unless you really need it.

 - Anna
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[wtr-general] Re: IE instance problem

2009-04-01 Thread Vikas Tulashyam

Hi Anna,
Thanks. I solved this prob.. Thnak you very much

Thanks
Vikas

On Apr 1, 1:18 pm, Vikas Tulashyam vtulash...@gmail.com wrote:
 Hi,
 Thanks for the time. It returns hash values but I want to use this
 value into methods for objects identification like-

 a= get_object_locator(Text1)

 ie.text_field(a).set(test)

 Here, it's not working as it is.So how I can use this. I am very new
 to Watir and don't have too much idea. Sorry to bother you guys again
 and again.

 Thanks
 Vikas

 On Apr 1, 12:24 pm, Anna Gabutero a...@lavabit.com wrote:

  P.S. Starting your variable names with $ turns them into global
  variables.  Avoid doing so unless you really need it.

  - Anna
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[wtr-general] Re: IE instance problem

2009-03-31 Thread Vikas Tulashyam

Hi ,
Thanks for the time, actually I am creating a some common methods and
for that I have created some classes and I want to work on the same
IE instance, means all the classes should access the same IE instance
and perform the operations on the same IE. I have written the classes
in separate Ruby files. So is there any way to solve this problem.

Thanks
Vikas


On Mar 30, 7:24 pm, Željko Filipin zeljko.fili...@wa-research.ch
wrote:
 On Mon, Mar 30, 2009 at 16:13, Vikas Tulashyam vtulash...@gmail.com wrote:
  I can just create a variable instance of browser and use it
  whenever required.

 You want variable to point to a browser, but not open a new browser?

 Can you give us some information about what are you doing?

 Željko
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[wtr-general] Re: IE instance problem

2009-03-31 Thread Željko Filipin
On Tue, Mar 31, 2009 at 13:46, Vikas Tulashyam vtulash...@gmail.com wrote:
 I am creating a some common methods and
 for that I have created some classes and I want to work on the same
 IE instance, means all the classes should access the same IE instance
 and perform the operations on the same IE. I have written the classes
 in separate Ruby files.

There are several ways of solving the problem:

1) use global variable for browser, like $browser, and all your scripts will
have access to it
2) send variable that points to browser to method as parameter:

def do_something(browser)
  browser.goto google.com
end

browser = Watir:IE.new
do_something(browser)

There are more solutions, but this two look the simplest to me.

Željko

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[wtr-general] Re: IE instance problem

2009-03-31 Thread Vikas Tulashyam

Hi,
Thanks for the reply, your exaple is useful. can you please gide me
more for the following problem--


Hi All,
I want to return a instance of a browser and a prticular method
related to the browser from a function --
Following is the my code--

def getObjectLocator(sObjectId)
begin
  $sObjectFile.elements.each(//TestObject[Identifier='#
   {sObjectId}']) { |element|
sLocator = element.elements['Locator'].text
sObjectType = element.elements['ObjType'].text

if(sObjType.eql?(TextField))
s = Watir.IE.new
s.text_field(sLocator)
return s
 }
end

Here, sLocator is-- :name,'q'. I am not able to return the instance
of this text filed which has the property as sLocator. if I write the
code as --

  s.text_field(:name,'q') , then it's working fine but it's nt working
with s.text_field(sLocator). Here sLocator contains the same value
i.e. :name,'q'.

please help me.

Thanks
Vikas

 but I am facing some other

Željko Filipin wrote:
 On Tue, Mar 31, 2009 at 13:46, Vikas Tulashyam vtulash...@gmail.com wrote:
  I am creating a some common methods and
  for that I have created some classes and I want to work on the same
  IE instance, means all the classes should access the same IE instance
  and perform the operations on the same IE. I have written the classes
  in separate Ruby files.

 There are several ways of solving the problem:

 1) use global variable for browser, like $browser, and all your scripts will
 have access to it
 2) send variable that points to browser to method as parameter:

 def do_something(browser)
   browser.goto google.com
 end

 browser = Watir:IE.new
 do_something(browser)

 There are more solutions, but this two look the simplest to me.

 Željko
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[wtr-general] Re: IE instance problem

2009-03-31 Thread Vikas Tulashyam


Hi,
Thanks for the reply . I tried the method suggested by you,

sLocator = {:name='q'}
return $sBrowser.text_field(sLoc)

but it's not working it gives the following error-- c:/ruby/lib/ruby/
gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:
102:in `const_missing': uninitialized constant
Watir::InputElementLocator::MissingWayOfFindingObjectException
(NameError)

Please help.

Thanks
Vikas


On Mar 31, 5:55 pm, Željko Filipin zeljko.fili...@wa-research.ch
wrote:
 On Tue, Mar 31, 2009 at 14:47, Vikas Tulashyam vtulash...@gmail.com wrote:
   s.text_field(:name,'q') , then it's working fine but it's nt working
  with s.text_field(sLocator). Here sLocator contains the same value
  i.e. :name,'q'.

 Try putting this to sLocator:

 {:name = 'q'}

 instead of:

 :name, 'q'

 Željko
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[wtr-general] Re: IE instance problem

2009-03-31 Thread Vikas Tulashyam

Hi firends,
Please help me.

Thanks
Vikas


On Mar 31, 6:24 pm, Vikas Tulashyam vtulash...@gmail.com wrote:
 Hi,
 Actually, I am trying to read the sLocator value form a xml file and
 thats the main problem if I put the value directly into a variable
 then it's working fine like--

 a= {:name='q'}
 return $sBrowser.text_field(a)

 Code written above works fine but when I m doing this-

         sLoc = getObjectLocator(Text_Search)
         return $sBrowser.text_field(sLoc)

         def getObjectLocator(sObjectId)
         begin
           $sObjectFile = Document.new File.new(c:\\a.xml)

           $sObjectFile.elements.each(//TestObject[Identifier='#
 {sObjectId}']) { |element|
             sLocator = element.elements['Locator'].text
             sObjectType = element.elements['ObjType'].text
             return sLocator
           }

 sLoc returns the correct value, I tried this by printing the sLoc
 value but It is nt working

 My Xml file looks like--

 - ObjectMap
 - TestObject
   IdentifierList_All/Identifier
   Locator:name, 'options'/Locator
   ObjTypeSelect List/ObjType
   /TestObject
 - TestObject
   IdentifierText_Search/Identifier
   Locator{:name='q'}/Locator
   ObjTypeTextField/ObjType
   /TestObject
   /ObjectMap

 Thanks
 Vikas

 On Mar 31, 6:14 pm, Vikas Tulashyam vtulash...@gmail.com wrote:

  Hi,
  Thanks for the reply . I tried the method suggested by you,

  sLocator = {:name='q'}
  return $sBrowser.text_field(sLoc)

  but it's not working it gives the following error-- c:/ruby/lib/ruby/
  gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:
  102:in `const_missing': uninitialized constant
  Watir::InputElementLocator::MissingWayOfFindingObjectException
  (NameError)

  Please help.

  Thanks
  Vikas

  On Mar 31, 5:55 pm, Željko Filipin zeljko.fili...@wa-research.ch
  wrote:

   On Tue, Mar 31, 2009 at 14:47, Vikas Tulashyam vtulash...@gmail.com 
   wrote:
 s.text_field(:name,'q') , then it's working fine but it's nt working
with s.text_field(sLocator). Here sLocator contains the same value
i.e. :name,'q'.

   Try putting this to sLocator:

   {:name = 'q'}

   instead of:

   :name, 'q'

   Željko
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[wtr-general] Re: IE instance problem

2009-03-30 Thread Željko Filipin
On Mon, Mar 30, 2009 at 16:13, Vikas Tulashyam vtulash...@gmail.com wrote:
 I can just create a variable instance of browser and use it
 whenever required.

You want variable to point to a browser, but not open a new browser?

Can you give us some information about what are you doing?

Željko

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---