我正在使用NightmareJS创建Web自动化软件。我想为我的软件创建一个GUI,但我无法弄清楚如何同时使用Electron窗口和无头NightmareJS进程。目标是能够通过GUI Electron线程控制NightmareJS线程。以下是使用Nightmare对我来说的样子:
const Promise = require("bluebird");
const Nightmare = require('nightmare');
require('nightmare-upload')(Nightmare);
const vo = require('vo');
const realMouse = require('nightmare-real-mouse');
const request = require("request");
const qs = require('querystring')
const EventEmitter = require("events").EventEmitter;
const cheerio = require('cheerio');
const rp = require('request-promise');
var run = function* () {
const nightmare = Nightmare({
show: true,
switches: {
'ignore-certificate-errors': true
},
waitTimeout: 90000,
gotoTimeout: 90000
});
yield nightmare.goto("https://www.google.com");
yield nightmare.wait(5000);
yield nightmare.end(() => "some value");
yield nightmare.then(function () {
console.log("ended");
});
}
vo(run)(function (err, titles) {
console.dir(titles);
});