Retrieving and entering a variable... is it possible?

52 views
Skip to first unread message

tko...@pictage.com

unread,
Jul 18, 2011, 8:16:53 PM7/18/11
to Fitnium
Ok, so what I'm trying to do is take the text of one page element,
save it to a variable, and then enter that into another input box on
the page I'm testing.

The reason I'm trying to do this is because I need to set a field
called "orderDate" with whatever date it is when the test was run. I
tried to use the date API but the date is in the wrong format. The
page will only accept a date if it's entered like so... "07/18/2011"
The date API enters the date as "07-18-2011". If anyone had any
suggestions it would be appreciated. I can't seem to get any further
with variables other than defining static ones, and then using them in
my tests. Is there any way to pull the text of a page element and
then plug it back into the web page?

My last attempt to do this looked something like this...

|set fitnium variable called | tomDate | with value | text |

|store text of element| xpath=//*[@id="due_date"] | in | tomDate |

|enter | tomDate | in input field | //input[@id="order_date"] |

Sincerely,

-Tom

tnels.cisc

unread,
Jul 27, 2011, 3:37:12 PM7/27/11
to Fitnium
| store input field | xpath=//*[@id="due_date"] | is editable in |
tomDate |
|enter | !{tomDate} | in input field | //input[@id="order_date"] |

This might work,
-Tom

tko...@pictage.com

unread,
Jul 27, 2011, 4:17:37 PM7/27/11
to Fitnium
That almost works. It inserts the value "True" into the text field.
Seems to be setting it as bool and not the String value. I'll have to
look at some examples of the store command.

tko...@pictage.com

unread,
Jul 27, 2011, 5:03:20 PM7/27/11
to Fitnium
I did notice a date command in Fitnesse... you can read about it here.
http://fitnesse.org/FitNesse.UserGuide.TodaysDate

Still, I can't seem to format the date the way I need it. I almost
with Fitnesse had search and replace features like "sed" on the
command line. I'm sure there's a way to do it. It's just my
inexperience with the tool that's getting in the way right now.

-Tom

tko...@pictage.com

unread,
Jul 27, 2011, 5:16:10 PM7/27/11
to Fitnium
Bingo! Just figured out current date in Fitnesse and got my test
working. But did not answer my original question about storing and
pasting variables. Regardless, here's how you do current date.

| enter | !today (MM/d/yyyy) | in input field | //
input[@id="order_date"] |

Changes to how you need the date format are documented here...

http://download.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html

If I do find out how to get the variables working I'll be sure to
follow up.

-Tom

On Jul 27, 2:03 pm, "tko...@pictage.com" <tko...@pictage.com> wrote:
> I did notice a date command in Fitnesse... you can read about it here.http://fitnesse.org/FitNesse.UserGuide.TodaysDate

Keith Sterling

unread,
Jul 27, 2011, 5:21:39 PM7/27/11
to Fitnium
The Fitnium API

| store input field | xpath=//*[@id="due_date"] | is editable in |
tomDate |

Does in deed store a boolean, It is storing true or false, based on if
the input field 'is editiable'

Not the content of the input field

K

On Jul 27, 10:16 pm, "tko...@pictage.com" <tko...@pictage.com> wrote:
> Bingo!  Just figured out current date in Fitnesse and got my test
> working.  But did not answer my original question about storing and
> pasting variables.  Regardless, here's how you do current date.
>
> | enter | !today (MM/d/yyyy) | in input field | //
> input[@id="order_date"] |
>
> Changes to how you need the date format are documented here...
>
> http://download.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDate...
Reply all
Reply to author
Forward
0 new messages