Skip to content

Commit 009eb98

Browse files
authored
Merge pull request #36 from joao-voltarelli/fix/wait_for_downloads
BUG: updated wait_for_downloads method when headless
2 parents 51984b2 + 0e8231e commit 009eb98

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

botcity/web/bot.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,17 @@ def wait_for_downloads(self, timeout: int = 120000):
10221022
Args:
10231023
timeout (int, optional): Timeout in millis. Defaults to 120000.
10241024
"""
1025+
if self.browser in [Browser.CHROME, Browser.EDGE] and self.headless:
1026+
start_time = time.time()
1027+
while True:
1028+
elapsed_time = (time.time() - start_time) * 1000
1029+
if elapsed_time > timeout:
1030+
return False
1031+
downloads_count = self.get_file_count(self.download_folder_path, ".crdownload")
1032+
if downloads_count == 0:
1033+
return True
1034+
self.sleep(config.DEFAULT_SLEEP_AFTER_ACTION)
1035+
10251036
wait_method = BROWSER_CONFIGS.get(self.browser).get("wait_for_downloads")
10261037
# waits for all the files to be completed
10271038
WebDriverWait(self._driver, timeout/1000, 1).until(wait_method)

0 commit comments

Comments
 (0)