diff --git a/Dockerfile b/Dockerfile index fd9c9a5..b64109c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,10 +16,10 @@ RUN apt-get update && \ wget \ curl \ unzip \ - chromium-driver \ build-essential \ libsqlite3-dev \ sqlite3 \ + chromium \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* @@ -27,10 +27,11 @@ RUN apt-get update && \ RUN pip install --no-cache-dir -r requirements.txt # Set up Chrome WebDriver for Selenium -RUN wget -q -O /app/chromedriver.zip https://chromedriver.storage.googleapis.com/114.0.5735.90/chromedriver_linux64.zip && \ +RUN wget -q -O /app/chromedriver.zip https://storage.googleapis.com/chrome-for-testing-public/129.0.6668.70/linux64/chromedriver-linux64.zip && \ unzip /app/chromedriver.zip && \ + mv /app/chromedriver-linux64/chromedriver /app && \ chmod +x /app/chromedriver && \ - rm /app/chromedriver.zip + rm -rf /app/chromedriver.zip /app/chromedriver-linux64 # Set environment variables for Chrome and ChromeDriver ENV PATH=/app:$PATH diff --git a/requirements.txt b/requirements.txt index f2f0115..0d9a0ed 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,3 +8,4 @@ google-auth==2.34.0 google-auth-httplib2==0.2.0 google-auth-oauthlib==1.2.1 googleapis-common-protos==1.65.0 +webdriver-manager==4.0.2 diff --git a/xclient.py b/xclient.py index eee83af..7463217 100644 --- a/xclient.py +++ b/xclient.py @@ -8,6 +8,10 @@ import time import requests import config from selenium.webdriver.chrome.service import Service +from webdriver_manager.chrome import ChromeDriverManager + + +service = Service(ChromeDriverManager().install()) class XClient: @@ -28,16 +32,19 @@ class XClient: def fetch_access_token(self): # Set up the WebDriver (make sure to use the correct path for your WebDriver) + print("starting chromedriver") options = webdriver.ChromeOptions() options.add_argument("--headless=new") options.add_argument("--no-sandbox") - service = Service(executable_path=config.CHROMEDRIVER_PATH) + print("started chromedriver") driver = webdriver.Chrome(options=options, service=service) driver.get("https://x.tudelft.nl") + print("Check1") + button = WebDriverWait(driver, 30).until( EC.element_to_be_clickable( (By.XPATH, "//span[contains(text(), 'TUDelft')]") @@ -53,6 +60,8 @@ class XClient: ) ) ) + + print("Check2") button.click() # Input the username