I want to use testcafe to start browsers available through internal end external browser providers. I don't want any testing functionality. But I want to be able to use takeScreenshot, resizeWindow, etc.
Here is my code.
const pool = require("./node_modules/testcafe/lib/browser/provider/pool.js");
pool.getProvider("chrome").then((provider) => {
const plugin = provider.plugin;
console.log("open")
plugin.openBrowser("foo", "http://google.de", "chrome").then(() => {
console.log("done");
}).catch(console.warn);;
console.log("early");
}).catch(console.warn);
If I run or debug the file with this code, the open browser promise is never resolved. The console prints open
and early
and then the program exits.
If I copy and paste the code into an interactive node shell, the browser gets started. (I get an exception that connection is null but this code is never run if I start the file.
What am I doing wrong?
UPDATE: This is the code that uses async/await, but does not work either:
const pool = require("../node_modules/testcafe/lib/browser/provider/pool.js");
(async () => {
const provider = await pool.getProvider("chrome");
const plugin = provider.plugin;
await plugin.openBrowser("foo", "http://google.de", "chrome");
console.log("done");
})();