Skip to content

Commit d35319e

Browse files
committed
waiting for notebook finished done
1 parent 2429038 commit d35319e

File tree

1 file changed

+7
-31
lines changed

1 file changed

+7
-31
lines changed

tests/e2e/tutorials/jupyters.js

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,10 @@ async function runTutorial() {
4141

4242
// inside the iFrame, open the first notebook
4343
const notebookCBSelector = '#notebook_list > div:nth-child(2) > div > input[type=checkbox]';
44-
await nbIframe.waitForSelector(notebookCBSelector);
45-
await nbIframe.click(notebookCBSelector);
44+
await utils.waitAndClick(nbIframe, notebookCBSelector)
4645
await tutorial.waitFor(2000);
4746
const notebookViewSelector = "#notebook_toolbar > div.col-sm-8.no-padding > div.dynamic-buttons > button.view-button.btn.btn-default.btn-xs"
48-
await nbIframe.waitForSelector(notebookViewSelector);
49-
await nbIframe.click(notebookViewSelector);
47+
await utils.waitAndClick(nbIframe, notebookViewSelector)
5048
await tutorial.waitFor(2000);
5149
await tutorial.takeScreenshot("openNotebook");
5250

@@ -57,35 +55,13 @@ async function runTutorial() {
5755
const confirmRunAllButtonSelector = 'body > div.modal.fade.in > div > div > div.modal-footer > button.btn.btn-default.btn-sm.btn-danger';
5856
await utils.waitAndClick(nbIframe, confirmRunAllButtonSelector)
5957
// now check that the input contains [4]
58+
console.log('Waiting for notebook results...');
6059
const finishedRunningCheckboxSelector = '#notebook-container > div:nth-child(5) > div.input > div.prompt_container > div.prompt.input_prompt';
61-
await nbIframe.waitForSelector(finishedRunningCheckboxSelector);
60+
await nbIframe.waitForFunction('document.querySelector("' + finishedRunningCheckboxSelector + '").innerText.match(/\[[0-9]+\]/)')
61+
const element = await nbIframe.$(finishedRunningCheckboxSelector)
62+
const value = await nbIframe.evaluate(el => el.textContent, element);
63+
console.log('Checking results for the notebook cell:', value);
6264

63-
64-
let inputElement = await nbIframe.$(finishedRunningCheckboxSelector);
65-
66-
67-
68-
// async function checkNotebookCompleted(page, el) {
69-
// let value = await page.evaluate(el => el.textContent, el);
70-
// return value.match(/\[[0-9]+\]/) != null;
71-
// }
72-
await nbIframe.waitForFunction(async (page, el) => {
73-
let value = await page.evaluate(el => el.textContent, el);
74-
if (value.match(/\[[0-9]+\]/)) {
75-
return true;
76-
} else {
77-
return false;
78-
}
79-
}, {}, nbIframe, inputElement);
80-
// await nbIframe.waitForFunction(async (page, selector) => {
81-
// element = await page.$(selector);
82-
// return element.innerText.match(/\[[0-9]+\]/) != null;
83-
// }, { polling: 200, timeout: 20000 }, nbIframe, finishedRunningCheckboxSelector);
84-
// checkNotebookCompleted(nbIframe, inputElement, /\[[0-9]+\]/g), { polling: 200, timeout: 20000 });
85-
86-
87-
88-
console.log('Checking results for the notebook:');
8965
await tutorial.openNodeFiles(1);
9066
const outFiles = [
9167
"TheNumberNumber.txt",

0 commit comments

Comments
 (0)