type into a textfield with keypress event disabled

A colleague asked me how to automate a disabled text-box which has a calendar attached to it. The customer has specified that they want keyboard entries disabled for this text-field, hence every user of the website has to use the calendar drop down.

testfield calendar

Previously, this has been automated by using webdriver to type the text into the text box but as it was disabled, this was impossible.

imagine, this is the html for the textbox:


<input type="text" id="text_box_identifier" value="" disabled >

Using a javascript library such as jQuery, i was able to set this field using


$('#text_box_identifier').attr("value","27/05/2012");

Hope that saves you some time today ….

Advertisements
This entry was posted in Software Testing and tagged , , , , , , , . Bookmark the permalink.

2 Responses to type into a textfield with keypress event disabled

  1. Viresh Doshi says:

    It’s good to share , even the small tips can save time!.thank you for sharing!
    Time2test

  2. M.A. says:

    +1 Your tip helped me resolve this issue. Keep it up.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s