Skip to content

Commit 562c408

Browse files
committed
FIX: Add sleep in undetected chrome windows issue
1 parent 098de12 commit 562c408

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

conftest.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33
import shutil
44
import tempfile
5+
import time
56

67
import pytest
78
import typing
@@ -18,6 +19,12 @@
1819
TEST_PAGE = "https://lf2a.github.io/webpage-test/test.html"
1920
INDEX_PAGE = "https://lf2a.github.io/webpage-test/"
2021

22+
platforms = {
23+
"Linux": "linux",
24+
"Darwin": "mac",
25+
"Windows": "windows"
26+
}
27+
2128

2229
def get_fake_bin_path(web: WebBot) -> str:
2330
return os.path.join(web.download_folder_path, 'fake.bin')
@@ -58,11 +65,6 @@ def setup_edge(headless: bool, tmp_folder: str, download_driver: str) -> WebBot:
5865
web.driver_path = download_driver
5966
web.download_folder_path = tmp_folder
6067
opt = browsers.edge.default_options(headless=headless, download_folder_path=tmp_folder)
61-
platforms = {
62-
"Linux": "linux",
63-
"Darwin": "mac",
64-
"Windows": "windows"
65-
}
6668
platform_name = platforms.get(platform.system())
6769

6870
opt.platform_name = platform_name
@@ -117,6 +119,9 @@ def download_driver(request):
117119
manager = factory_driver_manager(browser=browser)
118120
installed_driver = manager(path=folder_driver).install()
119121
yield installed_driver
122+
# Issue: https://github.com/ultrafunkamsterdam/undetected-chromedriver/issues/551
123+
if platforms.get(platform.system()) == "windows" and browser == Browser.UNDETECTED_CHROME:
124+
time.sleep(3)
120125
shutil.rmtree(folder_driver)
121126

122127

@@ -139,4 +144,3 @@ def get_event_result(id_event: str, web: WebBot) -> typing.Dict:
139144
def pytest_addoption(parser):
140145
parser.addoption('--headless', action='store', default="true")
141146
parser.addoption('--browser', action='store', default='chrome')
142-

0 commit comments

Comments
 (0)