Skip to content

Commit 0e1ac19

Browse files
navin772diemol
andauthored
[py][tests]: check for .txt file in remote download test (#15758)
check for .txt file in test Co-authored-by: Diego Molina <[email protected]>
1 parent 65ffd18 commit 0e1ac19

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

py/test/selenium/webdriver/remote/remote_downloads_tests.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,15 @@ def test_get_downloadable_files(driver, pages):
3535
def test_download_file(driver, pages):
3636
_browser_downloads(driver, pages)
3737

38-
file_name = driver.get_downloadable_files()[0]
38+
# Get a list of downloadable files and find the txt file
39+
downloadable_files = driver.get_downloadable_files()
40+
text_file_name = next((file for file in downloadable_files if file.endswith(".txt")), None)
41+
assert text_file_name is not None, "Could not find a .txt file in downloadable files"
42+
3943
with tempfile.TemporaryDirectory() as target_directory:
40-
driver.download_file(file_name, target_directory)
44+
driver.download_file(text_file_name, target_directory)
4145

42-
target_file = os.path.join(target_directory, file_name)
46+
target_file = os.path.join(target_directory, text_file_name)
4347
with open(target_file, "r") as file:
4448
assert "Hello, World!" in file.read()
4549

0 commit comments

Comments
 (0)