Spaces:
Sleeping
Sleeping
Refactor chromedriver setup and WebDriverWait in capture_page function for improved readability
Browse files
src/modules/apps/__init__.py
CHANGED
|
@@ -53,7 +53,7 @@ def capture_page(url: str, output_file: str = "screenshot.png"):
|
|
| 53 |
|
| 54 |
# Set up Chrome service with explicit path to chromedriver and logging
|
| 55 |
service = Service(
|
| 56 |
-
executable_path='/usr/local/bin/chromedriver',
|
| 57 |
log_output=PIPE, # Redirect logs to pipe
|
| 58 |
service_args=['--verbose'] # Enable verbose logging
|
| 59 |
)
|
|
@@ -78,9 +78,9 @@ def capture_page(url: str, output_file: str = "screenshot.png"):
|
|
| 78 |
# Additional wait for dynamic content
|
| 79 |
from selenium.webdriver.support.ui import WebDriverWait
|
| 80 |
from selenium.webdriver.support import expected_conditions as EC
|
| 81 |
-
WebDriverWait(driver, 10).until(
|
| 82 |
-
|
| 83 |
-
)
|
| 84 |
|
| 85 |
print("Taking screenshot...")
|
| 86 |
driver.save_screenshot(output_file)
|
|
|
|
| 53 |
|
| 54 |
# Set up Chrome service with explicit path to chromedriver and logging
|
| 55 |
service = Service(
|
| 56 |
+
# executable_path='/usr/local/bin/chromedriver',
|
| 57 |
log_output=PIPE, # Redirect logs to pipe
|
| 58 |
service_args=['--verbose'] # Enable verbose logging
|
| 59 |
)
|
|
|
|
| 78 |
# Additional wait for dynamic content
|
| 79 |
from selenium.webdriver.support.ui import WebDriverWait
|
| 80 |
from selenium.webdriver.support import expected_conditions as EC
|
| 81 |
+
# WebDriverWait(driver, 10).until(
|
| 82 |
+
# lambda d: d.execute_script('return document.readyState') == 'complete'
|
| 83 |
+
# )
|
| 84 |
|
| 85 |
print("Taking screenshot...")
|
| 86 |
driver.save_screenshot(output_file)
|