Skip to content
Advertisement

jQuery 1.7.1 “on” function does not work with regular Javascript event trigger

I register the following function

//EDIT: updated
$("#id").on("change", function() {
  alert('xxx');
});

In my IE console I did

document.getElementById('id').onchange();

and it says element this does not have property or value.

I am trying to run automation test using

selenium.runScript("document.getElementById('id').onchange();");

What are ways around this? In IE I get JavaScript error popping up, thus stopping rest of the test.

Advertisement

Answer

Thanks I found the answer. I had to use

selenium.runScript($("#id").change());

even if I had added the missing quote.

If you register listener with on it doesn’t get register by the dom’s onchange event.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement