I am trying to (with minimal python knowledge) build a simple program that can upload a file to https://new.express.adobe.com/tools/remove-background let it process, and download the result. I've had chatGPT write some basic code for me but I can't get the upload portion working. I'm not sure if the issue is that I do not have the correct selector for the upload button or if there is some other issue standing in the way. Here is the full code I'm working with currently.
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
chromedriver_path = r"***"
service = Service(chromedriver_path)
driver = webdriver.Chrome(service=service)
url = "https://new.express.adobe.com/tools/remove-background"
driver.get(url)
# Wait for the file input to be present
WebDriverWait(driver, 20).until(
EC.presence_of_element_located((By.ID, "file-input"))
)
# Send the file path directly to the input element
file_input = driver.find_element(By.ID, "file-input")
file_path = r"***"
file_input.send_keys(file_path)
# Wait for the download button to appear
download_button = WebDriverWait(driver, 20).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, "sp-button[data-export-option-id='downloadExportOption']"))
)
download_button.click()
# Wait for and click the sign-in button
sign_in_button = WebDriverWait(driver, 10).until(
EC.element_to_be_clickable((By.CSS_SELECTOR, "sp-link.modal-sign-in-link"))
)
sign_in_button.click()
# Enter email and continue
email_input = WebDriverWait(driver, 10).until(
EC.visibility_of_element_located((By.ID, "EmailPage-EmailField"))
)
email_input.send_keys("***")
continue_button = driver.find_element(By.XPATH, "//span[contains(text(), 'Continue')]")
continue_button.click()
# Enter password and continue
password_input = WebDriverWait(driver, 10).until(
EC.visibility_of_element_located((By.ID, "PasswordPage-PasswordField"))
)
password_input.send_keys("***")
continue_button = driver.find_element(By.XPATH, "//span[contains(text(), 'Continue')]")
continue_button.click()
# Wait for the save file dialog to open
time.sleep(5) # Adjust this delay as needed for the dialog to fully appear
# Simulate pressing 'Enter' to confirm the save action
pyautogui.press('enter')
driver.quit()
I have tried targeting a clickable element like dropzone-background and I've tried going directly to the file upload, as in the code I linked above. The result was the window opening, not being able to find or interact with the element, and then closing.