Skip to content

Commit 836ae59

Browse files
committed
Try to stabilise Safari ci
1 parent 5df440b commit 836ae59

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

scripts/automated-notebook-run-script.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,29 @@ def wait_for_idle_status(driver, current_cell, start_time, timeout):
4949

5050
print(current_cell.text)
5151

52+
def rewind_to_first_cell(cell):
53+
while True:
54+
prev = cell.find_elements(
55+
By.XPATH,
56+
"preceding-sibling::div[contains(@class,'jp-Notebook-cell')][1]"
57+
)
58+
if not prev:
59+
return cell
60+
cell = prev[0]
61+
62+
5263

5364
def run_notebook(driver, notebook_area, args):
5465
"""This functions runs all the cells of the notebook"""
5566
print("Running Cells")
5667
start_time = time.time()
68+
current_cell = driver.find_element(
69+
By.CSS_SELECTOR, ".jp-Notebook-cell.jp-mod-selected"
70+
)
71+
72+
current_cell = rewind_to_first_cell(current_cell)
73+
5774
while True:
58-
current_cell = driver.find_element(
59-
By.CSS_SELECTOR, ".jp-Notebook-cell.jp-mod-selected"
60-
)
6175
editor_divs = current_cell.find_elements(
6276
By.CSS_SELECTOR, ".jp-InputArea-editor div"
6377
)
@@ -114,6 +128,11 @@ def run_notebook(driver, notebook_area, args):
114128
wait_for_idle_status(driver, current_cell, start_time, args.timeout)
115129

116130

131+
current_cell = current_cell.find_elements(
132+
By.XPATH,
133+
"following-sibling::div[contains(@class,'jp-Notebook-cell')][1]"
134+
)
135+
117136
def download_notebook(driver):
118137
"""This function is used to download the notebook currently open."""
119138
print("Downloading notebook by clicking download button")

0 commit comments

Comments
 (0)