javascript - The element is clicked, but Page is not reloaded accordingly -
using phantom js, trying click <li>
element(target_element) , render page loads after it. element clicked successfully. but, on rendering, refreshed page not seen in output. have given enough wait item. code is:
page.open(address, function (status) { if (status !== 'success') { console.log('unable load address!'); phantom.exit(); } else { window.settimeout(function () { page.evaluate(function() { document.getelementbyid('custom_filters').style.visibility = "hidden"; var = document.getelementbyid('target_element'); var e = document.createevent('mouseevents'); e.initmouseevent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); console.log(a.dispatchevent(e)); waitforload = true; }); page.render(output); phantom.exit(); }, waittime); } });
does mean event has not triggered js function or doing wrong here?
no, didn't have wait time between click , render. settimeout
needs around calls need delayed.
page.evaluate(function() { document.getelementbyid('custom_filters').style.visibility = "hidden"; var = document.getelementbyid('target_element'); var e = document.createevent('mouseevents'); e.initmouseevent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); console.log(a.dispatchevent(e)); waitforload = true; }); window.settimeout(function () { page.render(output); phantom.exit(); }, waittime);
Comments
Post a Comment