You can store it in a true global variable like this
$id = ie.checkboxes[1].name
$id is the global variable ($ is what makes it global)
to then use it in the syntax you provided:
ie.text_field(:name,"document_id").set($id)
If you want to stay away from global variables you can do this as well:
id = ie.checkboxes[1].name
ie.text_field(:name,"document_id").set(id)
Note: you can also do instance variables (@id) and class variables (@@id)
depending on what context you are working in.
-andy
----Original Message Follows----
From: "Frank Legarreta" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: [Wtr-general] Need help assigning/resolving variables in WATIR
Date: Thu, 25 May 2006 11:07:00 -0400
Thank you so much Andy.
What you suggested worked perfectly in getting the document id into a
variable called id.
2 quick questions for you...
1) Can I store the value of "id" as a global variable? - If not, do you know
the syntax for storing variable contents to a file?
2) Do you know the syntax for getting the value back out of the variable in
this case "id"?
for example - If I wanted to substitue the value of id into a page, would
this be the syntax?
ie.text_field(:name,"document_id").set([id])
Thank you, Frank
Date: Wed, 24 May 2006 20:41:05 -0400
From: "Andy Sipe" <[EMAIL PROTECTED]>
Subject: Re: [Wtr-general] Need help assigning/resolving variables in
WATIR
To: [email protected]
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; format=flowed
If the item you are looking for is always a check box then this should get
you what you want
id = ie.checkboxes[1].name
#do other things with id
-andy
----Original Message Follows----
From: "Frank Legarreta" <[EMAIL PROTECTED]>
Reply-To: [email protected]
To: [email protected]
Subject: [Wtr-general] Need help assigning/resolving variables in WATIR
Date: Wed, 24 May 2006 16:17:51 -0400
I am testing a web based document management system that assigns a unique
Document Id to each document upon creation. Unfortunately viewing source
on the page is not an option, but
ie.html does give me the html source, however, in one continuous string.
Executing ie.show_all_objects on the page after creating a new document
results in a list of about a dozen document records with their unique
document ids (below represents the first record):
Name=
Id=
Checkbox
Name=DOCID-EFG-123-0
Id=remove
Value=on
Alt=
Src=
Question: What would be the WATIR and/or RUBY syntax to get this 1st
occurrence of the Document Id (in this case DOCID-EFG-123-0) into a
variable called document-id and then back out to be used in subsequent
scripts that require the document-id as input?
Note: I was able to accomplish this using Selenium, but WATIR was more
versatile with things such as multiple pop-up window handling.
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general