Skip to content

Commit fb5994c

Browse files
authored
Update automated-notebook-run-script.py
1 parent de816e0 commit fb5994c

File tree

1 file changed

+9
-43
lines changed

1 file changed

+9
-43
lines changed

scripts/automated-notebook-run-script.py

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def main():
109109
notebook_area.send_keys(Keys.SHIFT, Keys.ENTER)
110110
time.sleep(0.5)
111111

112-
time.sleep(5)
112+
time.sleep(600)
113113

114114
if args.driver == "chrome" or args.driver == "firefox":
115115
print("Saving notebook")
@@ -168,9 +168,13 @@ def main():
168168
return deepQuerySelector(document, "jp-button[data-command='docmanager:download']");
169169
"""
170170

171-
download_button = driver.execute_script(search_script)
171+
download_button = WebDriverWait(driver, 20).until(
172+
lambda d: d.execute_script(search_script)
173+
)
174+
175+
print("Found element:", download_button)
172176

173-
time.sleep(2)
177+
time.sleep(20)
174178
driver.execute_script(
175179
"""
176180
const el = arguments[0];
@@ -190,46 +194,8 @@ def main():
190194
""",
191195
download_button,
192196
)
193-
applescript = r'''
194-
set buttonInfo to {}
195-
196-
tell application "System Events"
197-
repeat with proc in (every process whose background only is false)
198-
set procName to name of proc
199-
try
200-
repeat with w in windows of proc
201-
repeat with b in (buttons of w)
202-
set bName to ""
203-
try
204-
set bName to name of b
205-
end try
206-
if bName is missing value or bName = "" then
207-
try
208-
set bName to description of b
209-
end try
210-
end if
211-
if bName is missing value or bName = "" then
212-
try
213-
set bName to role description of b
214-
end try
215-
end if
216-
if bName is missing value or bName = "" then
217-
set bName to "«no name»"
218-
end if
219-
220-
set end of buttonInfo to procName & " — " & bName
221-
end repeat
222-
end repeat
223-
end try
224-
end repeat
225-
end tell
226-
227-
return buttonInfo
228-
'''
229-
230-
result = subprocess.run(["osascript", "-e", applescript], capture_output=True, text=True)
231-
print(result.stdout)
232-
time.sleep(2)
197+
198+
time.sleep(20)
233199

234200
# Close browser
235201
driver.quit()

0 commit comments

Comments
 (0)