-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to end nightmare #835
Comments
@rosshinkley i want to stop the nightmare by a button |
Yes. I think in that case you'd want the |
i got u ok thanks a lot for ur answer |
@rosshinkley do you know maybe when We need it for project of ours. If that will not be soon, do you suggest any solutions ? Peace! |
I don't know about the halt() function but basically I did another workaround. Creating a nightmare window without calling end() Maybe you wanted a pause button too. But I suppose this one was the best thing I could come of with. First I do this to run nightmare inside electron, Then I use this index.html file. <button id="start">Start</button>
<button id="stop">Stop</button>
<b id="status">idle</b>
<b id="results"></b>
<script>
// We allow nightmare to wander in the global scope by defining it here,
// otherwise we would not be able to call it multiple times
var Nightmare = require('nightmare');
var nightmare;
var args = { show: true, alwaysOnTop: false };
document.getElementById("start").addEventListener("click", function(){
document.getElementById("status").innerHTML = "Searching for the gem";
// Here we start the Nightmare Instance
nightmare = Nightmare(args);
nightmare
.goto('http://yahoo.com')
.type('form[action*="/search"] [name=p]', 'github nightmare')
.click('form[action*="/search"] [type=submit]')
.wait('#main')
.evaluate(function () {
return document.querySelector('#main .searchCenterMiddle li a').href
})
.then(function (result) {
document.getElementById("results").innerHTML = result;
})
.catch(function (error) {
document.getElementById("results"). innerHtml = "Search failed: " + error;
});
})
document.getElementById("stop").addEventListener("click", function(){
nightmare
.end()
.then(function (result) {
document.getElementById("status").innerHTML = "Leaving Nightmare Speechless";
})
})
</script> It might look really stupid, but this works for me I guess. |
@entrptaher Wow, tnx a lot for trying to help mate, really appreciate! I will need to wait someone to do this for me, cause current guy who was doing this left the work. @entrptaher how can I get in contact with you ? My email is [email protected], so you can reach me there or join our internal chat on https://chat.vanila.io |
Thank you @entrptaher |
Glad to be of help. |
Thanks @entrptaher for your example! I've tried to rebuild your example, but nightmare isn't starting in my case. Could have a look at https://github.com/Raidus/test-electron-nightmare? |
Please how to end nightmare by separeted button i want to do a start and stop button
PS:
The text was updated successfully, but these errors were encountered: