@@ -60,8 +60,8 @@ def main():
6060 # driver option is chosen
6161 if args .driver == "chrome" :
6262 options = ChromeOptions ()
63- options .add_argument ("--headless" )
64- options .add_argument ("--no-sandbox" )
63+ # options.add_argument("--headless")
64+ # options.add_argument("--no-sandbox")
6565 driver = webdriver .Chrome (options = options )
6666
6767 elif args .driver == "firefox" :
@@ -106,12 +106,6 @@ def main():
106106 if args .driver == "chrome" or args .driver == "firefox" :
107107 print ("Running Cells" )
108108 while True :
109- run_menu = wait .until (
110- EC .element_to_be_clickable ((By .XPATH , "//li[normalize-space()='Run']" ))
111- )
112- actions .move_to_element (run_menu ).pause (0.1 ).click ().perform ()
113- actions .send_keys (Keys .DOWN ).send_keys (Keys .ENTER ).perform ()
114-
115109 focused_cell = driver .find_element (
116110 By .CSS_SELECTOR , ".jp-Notebook-cell.jp-mod-selected"
117111 )
@@ -130,27 +124,29 @@ def main():
130124
131125 if cell_is_waiting_for_input (driver ):
132126 print ("Cell requesting input" )
133- actions .send_keys (f"{ args .stdin } " ).perform ()
134- time .sleep (1.15 )
135- actions .send_keys (Keys .CONTROL , Keys .ENTER )
136- time .sleep (1.15 )
137- actions .move_to_element (focused_cell ).perform ()
138- time .sleep (1.15 )
127+ input_box = WebDriverWait (driver , 5 ).until (
128+ EC .visibility_of_element_located (
129+ (By .CSS_SELECTOR , ".jp-Stdin-input" )
130+ )
131+ )
132+ input_box .click ()
133+ input_box .send_keys (f"{ args .stdin } " )
134+ time .sleep (10 )
135+ input_box .send_keys (Keys .CONTROL , Keys .ENTER )
136+ next_cell = focused_cell .find_element (
137+ By .XPATH ,
138+ "following-sibling::div[contains(@class,'jp-Notebook-cell')][1]" ,
139+ )
139140 driver .execute_script (
140- """
141- var el = document.activeElement;
142- var evt = new KeyboardEvent('keydown', {
143- key: 'ArrowDown',
144- code: 'ArrowDown',
145- keyCode: 40,
146- which: 40,
147- bubbles: true
148- });
149- el.dispatchEvent(evt);
150- """
141+ "arguments[0].scrollIntoView({block:'center'});" , next_cell
151142 )
152- time .sleep (1.15 )
153- time .sleep (1.15 )
143+ next_cell .click ()
144+ run_menu = wait .until (
145+ EC .element_to_be_clickable ((By .XPATH , "//li[normalize-space()='Run']" ))
146+ )
147+ actions .move_to_element (run_menu ).pause (0.1 ).click ().perform ()
148+ actions .send_keys (Keys .DOWN ).send_keys (Keys .ENTER ).perform ()
149+ time .sleep (1.0 )
154150
155151 elif args .driver == "safari" :
156152 print ("Running all cells using Shift+Enter..." )
0 commit comments