Skip to content

Commit 558740b

Browse files
committed
[py] Fix tests
1 parent d12d961 commit 558740b

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

py/conftest.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,6 @@ def driver(request):
349349

350350
yield selenium_driver.driver
351351

352-
if selenium_driver is not None:
353-
if selenium_driver.driver_class == "Remote" and "se:downloadsEnabled" in selenium_driver.driver.capabilities:
354-
selenium_driver.driver.delete_downloadable_files()
355-
356352
if request.node.get_closest_marker("no_driver_after_test"):
357353
if selenium_driver is not None:
358354
try:

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,35 @@
1818
import os
1919
import tempfile
2020

21+
import pytest
22+
2123
from selenium.webdriver.common.by import By
2224
from selenium.webdriver.support.wait import WebDriverWait
2325

2426

27+
@pytest.mark.no_driver_after_test
2528
def test_get_downloadable_files(driver, pages):
2629
_browser_downloads(driver, pages)
2730
file_names = driver.get_downloadable_files()
2831
# TODO: why is Chrome downloading files as .html???
2932
# assert "file_1.txt" in file_names
3033
# assert "file_2.jpg" in file_names
31-
assert any(f in file_names for f in ("file_1.txt", "file_1.html"))
32-
assert any(f in file_names for f in ("file_2.jpg", "file_2.html"))
34+
assert any(f in file_names for f in ("file_1.txt", "file_1.htm", "file_1.html"))
35+
assert any(f in file_names for f in ("file_2.jpg", "file_2.htm", "file_2.html"))
3336
assert type(file_names) is list
3437

3538

39+
@pytest.mark.no_driver_after_test
3640
def test_download_file(driver, pages):
3741
_browser_downloads(driver, pages)
3842

3943
# Get a list of downloadable files and find the txt file
4044
downloadable_files = driver.get_downloadable_files()
4145
# TODO: why is Chrome downloading files as .html???
4246
# text_file_name = next((file for file in downloadable_files if file.endswith(".txt")), None)
43-
text_file_name = next((file for file in downloadable_files if file.endswith((".txt", ".html"))), None)
47+
text_file_name = next(
48+
(f for f in downloadable_files if all((f.endswith((".txt", ".htm", ".html")), f.startswith("file_1")))), None
49+
)
4450
assert text_file_name is not None, "Could not find file in downloadable files"
4551

4652
with tempfile.TemporaryDirectory() as target_directory:
@@ -51,6 +57,7 @@ def test_download_file(driver, pages):
5157
assert "Hello, World!" in file.read()
5258

5359

60+
@pytest.mark.no_driver_after_test
5461
def test_delete_downloadable_files(driver, pages):
5562
_browser_downloads(driver, pages)
5663

@@ -65,5 +72,5 @@ def _browser_downloads(driver, pages):
6572
# TODO: why is Chrome downloading files as .html???
6673
# WebDriverWait(driver, 5).until(lambda d: "file_2.jpg" in d.get_downloadable_files())
6774
WebDriverWait(driver, 5).until(
68-
lambda d: any(f in d.get_downloadable_files() for f in ("file_2.jpg", "file_2.html"))
75+
lambda d: any(f in d.get_downloadable_files() for f in ("file_2.jpg", "file_2.htm", "file_2.html"))
6976
)

0 commit comments

Comments
 (0)