The application under test emits 'page-load' event after every page load and I want to take screenshot after the page has successfully loaded. Tried to listen for this event using Leadfoot's execute method. But it does not seem to work. Can anyone point out if there is a way to successfully listen to events like page-load.
    return remote.get(URL) 
    .execute(function() {
                                        window.addEventListener('page-load',      function() {  
                                            console.log("Page ready");
                                        }, false);
                                    }, [])
    .takeScreenshot().then(function(data) {
                                        recordImage(newAddress, data);
                                    })
				
                        
Given that the event fires asynchronously and you want to wait to proceed until the event fires, you should use
executeAsyncinstead ofexecute. In addition to any arguments passed through,executeAsyncadds a callback argument that your code should call when the asynchronous operation completes.