javascript - How to handle onblur event with selenium webdriver -


i have onblur event need trigger when click away. using js as

((javascriptexecutor)getdriverprovider().executescript("document.getelementbyxpath('xpath here').onblur();"); 

but doesn't work. can suggest how handle case?

my proposal use js script (the js function fireevent):

function fireevent(el, type){    if ((el[type] || false) && typeof el[type] == 'function')    {      el[type](el);    }  }  $(function () {    $('#mybtn').mouseover(function(e) {      fireevent(document.getelementbyid('myinput'), 'blur');    });    $('#myinput').blur(function(e) {      alert('ok');    })  });
<script src="http://code.jquery.com/jquery-1.11.3.js"></script>      <input id="myinput">  <button id="mybtn">click me</button>


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -