|
@@ -6,7 +6,10 @@ async function main() {
|
|
|
/* eslint-disable no-console */
|
|
|
console.info('Starting Chrome Headless');
|
|
|
|
|
|
- const browser = await puppeteer.launch({ args: ['--no-sandbox'] });
|
|
|
+ const browser = await puppeteer.launch({
|
|
|
+ headless: true,
|
|
|
+ args: ['--no-sandbox']
|
|
|
+ });
|
|
|
const page = await browser.newPage();
|
|
|
|
|
|
console.info('Navigating to page:', URL);
|
|
@@ -38,13 +41,50 @@ async function main() {
|
|
|
console.error(`Parsed an error from text content: ${error.message}`, error);
|
|
|
}
|
|
|
|
|
|
- await page.evaluate(async () => {
|
|
|
+ function delay(duration) {
|
|
|
+ return function() {
|
|
|
+ return new Promise(function(resolve, reject) {
|
|
|
+ setTimeout(function() {
|
|
|
+ resolve();
|
|
|
+ }, duration);
|
|
|
+ });
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ const w1Id = await page.evaluate(async () => {
|
|
|
const jlab = window.jupyterlab;
|
|
|
const w1 = await jlab.commands.execute('fileeditor:create-new');
|
|
|
const w2 = await jlab.commands.execute('fileeditor:create-new');
|
|
|
- await jlab.shell.activateById(w1.id);
|
|
|
+ await new Promise((resolve, reject) => {
|
|
|
+ setTimeout(() => {
|
|
|
+ resolve();
|
|
|
+ }, 1000);
|
|
|
+ });
|
|
|
+ w1.content._ensureFocus();
|
|
|
+ await new Promise((resolve, reject) => {
|
|
|
+ setTimeout(() => {
|
|
|
+ resolve();
|
|
|
+ }, 1000);
|
|
|
+ });
|
|
|
+ // jlab.shell.activateById(w1.id);
|
|
|
+ // w2.activate();
|
|
|
+ // jlab._pluginMap['@jupyterlab/docmanager-extension:plugin'].service.mode;
|
|
|
+ return w1.id;
|
|
|
});
|
|
|
|
|
|
+ // foundId = await page.evaluate(async (w1Id) => {
|
|
|
+ // const jlab = window.jupyterlab;
|
|
|
+ // jlab.shell.activateById(w1Id);
|
|
|
+ // return jlab.shell.currentWidget.id;
|
|
|
+ // }, w1Id);
|
|
|
+
|
|
|
+ // const sel = "#" + w1Id + " .CodeMirror";
|
|
|
+ // console.log(sel);
|
|
|
+ // // await page.focus(sel);
|
|
|
+
|
|
|
+ // console.log(foundId);
|
|
|
+
|
|
|
+ await page.waitFor(2000);
|
|
|
console.log(page.url());
|
|
|
|
|
|
await browser.close();
|