« Return to Thread: onblur/onkeyup event

Re: onblur/onkeyup event

by bat :: Rate this Message:

Reply to Author | View in Thread

hi,

i have an input field which calls a javascript function upon onblur/onkeyup that does a check on the content of the specified textbox.
under certain conditions, a message is to be displayed by changing the visibility and innerText-property of another html element.

so what's going on is basically the following:
-----------------------------------------------------------
application_behaviour.js:
var myrules = {
//...
'#txtInput' : function( element )
{
  element.onblur = function()
  {
     //...
     check( this.value );
  }
 //...
  element.onkeyup  = function()
  {
    //...
    check( this.value );
  }
  //..
};
Behaviour.register(myrules);
-----------------------------------------------------------

-----------------------------------------------------------
page.html:
function check(value)
{
  //...
  document.getElementById(id).innerHTML = someText;
  document.getElementById(div1).style.visibility = "visible";
  document.getElementById(div2).style.visibility = "visible";
}
-----------------------------------------------------------

i have experimented a bit with <scriptStep>, but that doesn't seem to work.
apparantly for the same reason you mentioned here:

"there is a fundamental misunderstanding with the <scriptStep>: it allows to script webtest and ant, not to run script in the current page.
You can use <scriptStep> as well as <groovy> to script webtest and through webtest you can access the current page and start the execution of a javascript script in it. You have to look a the API of webtest and htmlunit for it. There is currently no special documentation for it as the right way would be to write a special step first not the doc for the hack."

unfortunately i cannot figure out how to actually access javascript on the webpage.
is it possible with an acceptable amount of work/explanation?  is there a working example somewhere?
it is not a crucial short-term-requirement for the test, so i might as well wait for the htmlunit solution if that can be expected within a reasonable time, but if i could solve it now, i'd certainly be very happy to.

thanks very much

christian


Marc Guillemot wrote:
Hi Christian,

1. yes

2. in a first time this is an htmlunit issue. There is no "plan" just
waiting that someone proposes a good patch.
Then it needs to be usable from WebTest. For onblur it would be
transparent in most of the cases. For keyup webtest would need an
additional way to say that key have been pressed.

3. it depends a bit from what your handlers are doing.

Marc.

bat wrote:
> hello,
>
> from the corresponding forum entries i take it that neither onblur nor
> onkeyup are supported by webtest at this time.
>
> 1. is this correct?
> 2. are there any plans to include support for these events in the future?
> 3. is there any workaround for that right now?
>
> thanks a lot for your help
> christian

_______________________________________________
WebTest mailing list
WebTest@lists.canoo.com
http://lists.canoo.com/mailman/listinfo/webtest

 « Return to Thread: onblur/onkeyup event