File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1529,10 +1529,8 @@ def test_session_materials_modal(self):
15291529 ),
15301530 'Modal open button not found or not clickable' ,
15311531 )
1532- # FIXME: no idea why we need js instead of the following:
1533- # self.scroll_to_element(open_modal_button)
1534- # open_modal_button.click()
1535- self .driver .execute_script ("arguments[0].click();" , open_modal_button )
1532+ self .scroll_to_element (open_modal_button )
1533+ open_modal_button .click ()
15361534 WebDriverWait (self .driver , 2 ).until (
15371535 expected_conditions .visibility_of (modal_div ),
15381536 'Modal did not become visible after clicking open button' ,
@@ -1586,6 +1584,7 @@ def test_session_materials_modal(self):
15861584 )
15871585 self .scroll_to_element (open_modal_button )
15881586 open_modal_button .click ()
1587+ # self.driver.execute_script("arguments[0].click();", open_modal_button)
15891588 WebDriverWait (self .driver , 2 ).until (
15901589 expected_conditions .visibility_of (modal_div ),
15911590 'Modal did not become visible after clicking open button for refresh test' ,
Original file line number Diff line number Diff line change @@ -251,9 +251,13 @@ $(function () {
251251 }
252252 } ) ;
253253
254+ // offset the scrollspy to account for the menu bar
255+ const contentOffset = contentElement ? contentElement . offset ( ) . top : 0 ;
256+
254257 $ ( "body" )
255258 . attr ( "data-bs-spy" , "scroll" )
256259 . attr ( "data-bs-target" , "#righthand-nav" )
260+ . attr ( "data-bs-offset" , contentOffset )
257261 . scrollspy ( "refresh" ) ;
258262
259263 }
Original file line number Diff line number Diff line change 1111 from selenium import webdriver
1212 from selenium .webdriver .chrome .service import Service
1313 from selenium .webdriver .chrome .options import Options
14- from selenium .webdriver .common .action_chains import ActionChains
1514 from selenium .webdriver .common .by import By
1615 from selenium .webdriver .common .desired_capabilities import DesiredCapabilities
1716except ImportError as e :
@@ -86,8 +85,16 @@ def login(self, username='plain'):
8685
8786 def scroll_to_element (self , element ):
8887 """Scroll an element into view"""
89- actions = ActionChains (self .driver )
90- actions .move_to_element (element ).perform ()
88+ # Compute the offset to put the element in the center of the window
89+ win_height = self .driver .get_window_rect ()['height' ]
90+ offset = element .rect ['y' ] + (element .rect ['height' ] - win_height ) // 2
91+ self .driver .execute_script (
92+ 'window.scroll({top: arguments[0], behavior: "instant"})' ,
93+ offset ,
94+ )
95+ # The ActionChains approach below seems to be fragile, hence he JS above.
96+ # actions = ActionChains(self.driver)
97+ # actions.move_to_element(element).perform()
9198
9299
93100class presence_of_element_child_by_css_selector :
You can’t perform that action at this time.
0 commit comments