Skip to content Skip to sidebar Skip to footer

The Element Is Clicked, But Page Is Not Reloaded Accordingly

Using phantom JS, I am trying to click a
  • element(target_element) and render the page which loads after it. The element is clicked successfully. But, on rendering, the re
  • Solution 1:

    No, you didn't have any wait time between click and render. The setTimeout needs to be only around the calls that need to be delayed.

    page.evaluate(function() {
        document.getElementById('custom_filters').style.visibility = "hidden";
        var a = 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);
    

    Post a Comment for "The Element Is Clicked, But Page Is Not Reloaded Accordingly"