import tempfile
from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--window-size=1920,1200')
chrome_options.binary_location = "/usr/bin/chromium"

# TEMP DIR für User Data
user_data_dir = tempfile.mkdtemp()
chrome_options.add_argument(f'--user-data-dir={user_data_dir}')

try:
    driver = webdriver.Chrome(options=chrome_options)
    print("WebDriver erfolgreich gestartet!")
    print("Typ:", type(driver))
    print("Session ID:", driver.session_id)
    driver.get("https://www.example.com")
    print("Titel der Seite:", driver.title)
    driver.quit()
except Exception as e:
    print("Fehler beim Starten des WebDrivers:", e)
