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
Post a Comment