@@ -825,19 +825,27 @@ def on_download_end(info):
825825 driver .find_element (By .ID , "file-1" ).click ()
826826
827827 driver .find_element (By .ID , "file-2" ).click ()
828- WebDriverWait (driver , 5 ).until (lambda d : len (events_received ) > 1 )
828+ WebDriverWait (driver , 5 ).until (lambda d : len (events_received ) == 2 )
829829
830830 assert len (events_received ) == 2
831831
832- download_event = events_received [ 0 ]
833- assert download_event .download_params is not None
834- assert download_event .download_params .status == "complete"
835- assert download_event .download_params .context == context_id
836- assert download_event .download_params .timestamp is not None
837- assert "downloads/file_1.txt" in download_event . download_params . url
838- # we assert that atleast the str "file_1" is present in the downloaded file since multiple downloads
832+ for ev in events_received :
833+ assert ev .download_params is not None
834+ assert ev .download_params .status == "complete"
835+ assert ev .download_params .context == context_id
836+ assert ev .download_params .timestamp is not None
837+
838+ # we assert that atleast "file_1" is present in the downloaded file since multiple downloads
839839 # will have numbered suffix like file_1 (1)
840- assert "file_1" in download_event .download_params .filepath
840+ assert any (
841+ "downloads/file_1.txt" in ev .download_params .url and "file_1" in ev .download_params .filepath
842+ for ev in events_received
843+ )
844+
845+ assert any (
846+ "downloads/file_2.jpg" in ev .download_params .url and "file_2" in ev .download_params .filepath
847+ for ev in events_received
848+ )
841849
842850 driver .browsing_context .remove_event_handler ("download_end" , callback_id )
843851
0 commit comments