just_add_watir | Advanced recipes for Watir
23Aug/08Off

Q. How do I enter the current date or time into a textfield?

A. Use the Time.now method ...
Example html:

<html>
   <body>
      <form method="post" action="">
         <textarea name="comments" cols="40" rows="1">
            Enter your comments here...
         </textarea><br />
         <input type="submit" value="Submit" />
      </form>
   </body>
</html>

Example watir:

t=Time.now
@b.text_field(:name,"comments").set(t.strftime("%m/%d/%Y_%H%:M%"))
Tagged as: , , No Comments