Hi,

<groovy>
def jsIntrusion = "check('some value')"
def page = step.context.currentResponse
page.executeJavaScriptIfPossible(jsIntrusion, "intrusion code", false, null)
</groovy>

but take care to this note from executeJavaScriptIfPossible's javadoc:
-------------
Please note: Although this method is public, it is not intended for general execution of javascript. Users of HtmlUnit should interact with the pages as a user would by clicking on buttons or links and having the javascript event handlers execute as needed..
-------------

So you may find a workaround this way but the safer way would surely be to submit a patch allowing htmlunit/webtest to handle these events natively ;-)

Marc.

bat wrote:
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 http://www.nabble.com/calling-javascript-functions-tf1402316.html#a3804736
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
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest




_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest

Reply via email to