Skip to content
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

app.quit() is not noticed #131

Open
wojtkowiak opened this issue Oct 26, 2016 · 6 comments
Open

app.quit() is not noticed #131

wojtkowiak opened this issue Oct 26, 2016 · 6 comments

Comments

@wojtkowiak
Copy link

Testing if my app is quitting correctly 😄
After app.quit t.context.app.isRunning() still reports true.
https://github.com/electron/spectron/blob/aaf7b6964ed32f43c0955b0cb1af5eeb99938db0/lib/application.js#L86
t.context.app.stop() will fail with Error: chrome not reachable.
Manually doing t.context.app.running = false; fixes it.
Not sure if this should be handled but maybe a note in the readme would be useful. I am leaving it to your judgment ;)

@taboca
Copy link

taboca commented Oct 26, 2016

I noticed a quit trouble with my case of a browser-kyosk project. It happened after about 300 executions. I am using Linux, Ubuntu 14+ with:

"electron-prebuilt": "^1.3.8",
"spectron": "~3.4.0"

My case uses a a browser launcher script to launch and quit, first. When the script ends, an external (Forever daemon) system notices, and then it runs the node script again. Therefore, I have a sort of infinite testing cycle, which is by design. In this case it's a plain code (not using Mocha, etc) - the following source is the core of it aside from the external synchronous loop system.

From a visual perspective, it got stuck, with the browser window open. When I killed, then I noticed another was there. So prior to get stuck, I believe that a twice were shown somehow. Looking in logs, all of the iterations showed a proper "Quit" output. I would think that it was Forever that caused the trouble but since the browser is open, I then thought about this report here.


var app = new Application({
        path: electron, args:['.']
})

console.log('node version: ' + process.version);

app.start().then(function ok() {
                app.client.waitUntilTextExists('#message', 'success', 10000).then(
                        function success() {
                                console.log('Success, content loaded!!!');

                                app.stop().then(function ok() {
                                        console.log('Quit ')
                                }, function nok() {
                                        console.log('not quit properly!');
                                });

                        }, function nok() {
                                console.log("Not loaded...");

                                app.stop().then(function ok() {
                                        console.log('Quit ')
                                }, function nok() {
                                        console.log("not quit really");
                                });

                        });
}, function nok() {
        console.log('Start not ok!')
});

@taboca
Copy link

taboca commented Oct 26, 2016

I wonder if the chromedriver could be a reason here - mainly because I found this http://stackoverflow.com/questions/34563724/how-to-make-sure-only-single-chromedriver-exe-instance-is-running-in-background. And then it would be interesting to know exactly if spectron truly have full control over the chromedriver instance.

@MoonTahoe
Copy link

I am having the same problem. I have some tests that are checking to make sure the app quits when all windows have closed. app.isRunning() and app.running still remain true after the app quits.

I hacked out a work around by executing the pgrep command for the time being, but it will not work in windows, and it is not as nice as having app.isRunning() working:

    exec('pgrep <APPNAME>', (err, stdout) => {
        if (err) {
           // pgrep command did not work
           // electron app is not running
        } else {
          // pgrep found some processes associated with <APPNAME>
          // electron app is still running
       }
    })

@alexan
Copy link

alexan commented Sep 15, 2021

is there any new solution for this problem. I can not get a test working, to check if the application has quit()

@evertonlperes
Copy link

Having the same issue and seems app.stop() or app.quit() does not close the app at all :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants