Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using WebTestCase api how can to set value to hidden field

 
Annapoorni Moorthy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using WebTestCase for my httpunit test case version is 1.2. I have a form with input hidden field, the value of this hidden field is set through a JS function on submitting the form , I am clueless as to how to achieve this in test case , to submit the form previously we had a link , which on clicking calls the JS fucntion which sets the value and then submits the form , now the code has been changed to submit the form on pressing enter key. So I am stuck here , as to how to set the hidden filed value because setFormElement throws Exception as cannot set the value for hidden field , I came across methods like setHiddenField() but this version of WebTestCase wont soupport it . What can I try as other alternatives . If I am unclear please let me know , I ll try to be more specific.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Annapoorni Moorthy wrote:... now the code has been changed to submit the form on pressing enter key. So I am stuck here , as to how to set the hidden filed value because setFormElement throws Exception as cannot set the value for hidden field ,

Check if you can create Enter Key press event somehow using WebTestCase, OR atleast execute a JS script which will do that for you, something like done here: http://stackoverflow.com/questions/4832776/in-javascript-how-can-i-create-my-own-keyboard-event
 
Annapoorni Moorthy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sagar Rohankar wrote:
Annapoorni Moorthy wrote:... now the code has been changed to submit the form on pressing enter key. So I am stuck here , as to how to set the hidden filed value because setFormElement throws Exception as cannot set the value for hidden field ,

Check if you can create Enter Key press event somehow using WebTestCase, OR atleast execute a JS script which will do that for you, something like done here: http://stackoverflow.com/questions/4832776/in-javascript-how-can-i-create-my-own-keyboard-event


Thanks for the help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic