【问题标题】:Programmatically both start and kill a web browser using Node.js使用 Node.js 以编程方式启动和终止 Web 浏览器
【发布时间】:2015-08-19 05:49:49
【问题描述】:

如何使用 Node.js 以编程方式启动和终止 Web 浏览器?

类似这样的伪代码:

var spawn = require('child_process').spawn;

// This opens a browser and returns control to terminal, but optimally
// the process should run in the foreground and exit on ctrl-c.
spawn('open', ['http://www.stackoverflow.com']);

process.on('SIGINT', function() {
  // Kill the opened browser here
});

【问题讨论】:

  • 如果你想在这里得到答案,你必须出示相关的代码。
  • 听起来你是在询问使用哪个库的建议,这不是 StackOverflow 的用途
  • 如果您正在寻找像 Karma Test Runner 那样执行此操作的软件包,Juan Mendes 是正确的。如果您尝试在自己的代码中实现类似的行为,那么 Jonast92 是正确的(并且 Karma Test Runner 的代码似乎是寻找如何去做的线索的好地方)。请澄清是哪种情况。
  • 查看stackoverflow.com/questions/14031763/… 了解如何在ctrl-c 上做事。
  • 感谢您的 cmets。我已经从问题中删除了对其他库的引用,并添加了一些希望澄清事情的代码。

标签: javascript node.js browser


【解决方案1】:
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-10
  • 2013-12-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多