Skip to content

Commit 449e1e0

Browse files
committed
wait enough before getting results
the confirmation dialog does not come up in the notebook
1 parent 5534704 commit 449e1e0

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

tests/e2e/tutorials/jupyters.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,33 @@ async function runTutorial() {
4343
// inside the iFrame, open the first notebook
4444
const notebookCBSelector = '#notebook_list > div:nth-child(2) > div > input[type=checkbox]';
4545
await utils.waitAndClick(nbIframe, notebookCBSelector)
46-
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"
4847
await utils.waitAndClick(nbIframe, notebookViewSelector)
49-
await tutorial.waitFor(2000);
50-
await tutorial.takeScreenshot("openNotebook");
48+
5149

5250
// inside the first notebook, click Run all button
5351
const runAllButtonSelector = '#run_int > button:nth-child(4)';
54-
await utils.waitAndClick(nbIframe, runAllButtonSelector)
52+
await utils.waitAndClick(nbIframe, runAllButtonSelector);
53+
await tutorial.takeScreenshot("pressRunAllButtonNotebook");
54+
55+
// inside the first notebook, click confirm run all (NOTE: this dialog does not appear it seems)
56+
// const confirmRunAllButtonSelector = 'body > div.modal.fade.in > div > div > div.modal-footer > button.btn.btn-default.btn-sm.btn-danger';
57+
// await utils.waitAndClick(nbIframe, confirmRunAllButtonSelector);
58+
// await tutorial.takeScreenshot("pressRunNotebookAfterConfirmation");
5559

56-
// inside the first notebook, click confirm run all
57-
const confirmRunAllButtonSelector = 'body > div.modal.fade.in > div > div > div.modal-footer > button.btn.btn-default.btn-sm.btn-danger';
58-
await tutorial.takeScreenshot("pressRunNotebook");
59-
await utils.waitAndClick(nbIframe, confirmRunAllButtonSelector)
60-
await tutorial.takeScreenshot("pressRunNotebookAfterConfirm");
6160
// now check that the input contains [4]
6261
console.log('Waiting for notebook results...');
6362
const finishedRunningCheckboxSelector = '#notebook-container > div:nth-child(5) > div.input > div.prompt_container > div.prompt.input_prompt';
63+
// the page scrolls down, so first wait so that it becomes visible
64+
await nbIframe.waitForSelector(finishedRunningCheckboxSelector);
6465
await nbIframe.waitForFunction('document.querySelector("' + finishedRunningCheckboxSelector + '").innerText.match(/\[[0-9]+\]/)');
66+
await tutorial.takeScreenshot("notebookWaitingForNotebookCompleted");
67+
console.log('...waiting completed');
6568
const element = await nbIframe.$(finishedRunningCheckboxSelector);
6669
const value = await nbIframe.evaluate(el => el.textContent, element);
67-
await tutorial.takeScreenshot("notebookAfterRun");
68-
console.log('Checking results for the notebook cell:', value);
70+
console.log('Results for the notebook cell is:', value);
71+
// NOTE: we need to wait here to get the results.
72+
await tutorial.waitFor(10000);
6973

7074
await tutorial.openNodeFiles(1);
7175
const outFiles = [
@@ -92,12 +96,9 @@ async function runTutorial() {
9296
await jLabIframe.click(input2outputFileSelector, {
9397
clickCount: 2
9498
});
95-
await tutorial.waitFor(2000);
96-
9799
// click Run Menu
98100
const mainRunMenuBtnSelector = '#jp-MainMenu > ul > li:nth-child(4)';
99101
await utils.waitAndClick(jLabIframe, mainRunMenuBtnSelector)
100-
await tutorial.waitFor(1000);
101102

102103
// click Run All Cells
103104
const mainRunAllBtnSelector = ' body > div.lm-Widget.p-Widget.lm-Menu.p-Menu.lm-MenuBar-menu.p-MenuBar-menu > ul > li:nth-child(17)';
@@ -110,7 +111,8 @@ async function runTutorial() {
110111
const jLabVvalue = await jLabIframe.evaluate(el => el.textContent, jLabElement);
111112
console.log('Checking results for the jupyter lab cell:', jLabVvalue);
112113
await tutorial.takeScreenshot("pressRunJLab");
113-
await tutorial.waitFor(5000);
114+
// wait sufficiently before getting the results
115+
await tutorial.waitFor(10000);
114116
console.log('Checking results for the jupyter lab:');
115117
await tutorial.openNodeFiles(2);
116118
const outFiles2 = [

tests/e2e/utils/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ async function waitForValidOutputFile(page) {
303303
async function waitAndClick(page, id) {
304304
await page.waitForSelector(id, {
305305
timeout: 30000 // default 30s
306-
})
306+
});
307307
await page.click(id);
308308
}
309309

0 commit comments

Comments
 (0)