@@ -291,12 +291,35 @@ def click_file_download_warning_panel(self) -> BasePage:
291291 self .click_on ("file-download-warning-button" )
292292 return self
293293
294- @BasePage .context_chrome
295- def wait_for_download_elements (self ) -> BasePage :
294+ # @BasePage.context_chrome
295+ # def wait_for_download_elements(self) -> BasePage:
296+ # """
297+ # Wait for download elements to be present.
298+ # """
299+ # self.element_visible("download-target-element")
300+ # return self
301+
302+ def wait_for_item_to_download (self , filename : str ) -> BasePage :
296303 """
297- Wait for download elements to be present.
304+ Check the downloads tool in the toolbar to wait for a given file to download
298305 """
299- self .element_visible ("download-target-element" )
306+ original_timeout = self .driver .timeouts .implicit_wait
307+ try :
308+ # Whatever our timeout, we want to lengthen it because downloads
309+ self .driver .implicitly_wait (original_timeout * 2 )
310+ self .element_visible ("downloads-item-by-file" , labels = [filename ])
311+ self .expect_not (
312+ EC .element_attribute_to_include (
313+ self .get_selector ("downloads-button" ), "animate"
314+ )
315+ )
316+ with self .driver .context (self .context_id ):
317+ self .driver .execute_script (
318+ "arguments[0].setAttribute('hidden', true)" ,
319+ self .get_element ("downloads-button" ),
320+ )
321+ finally :
322+ self .driver .implicitly_wait (original_timeout )
300323 return self
301324
302325 @BasePage .context_chrome
0 commit comments