I’ve created a script using Python and Selenium to upload an image from a local folder to this webpage. The website requires a Google login to access the page with the upload option.
Once the login is complete, the site automatically redirects me to the target page. After the browser reaches the target page, it is necessary to click on Full Remake
. Now, the script tries to use the button Drag & Drop your image or Browse
to upload an image, but it selects the Browse
button and does nothing. This is the image I’m trying to upload on that site.
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
url = 'https://reroom.ai/'
options = webdriver.ChromeOptions()
options.add_argument("--disable-blink-features=AutomationControlled")
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
gmail = "" #gamil address here
password = "" #password here
driver.get(url)
original_window = driver.current_window_handle
driver.maximize_window()
try:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@type='button'][contains(.,'Accept')]"))).click()
except Exception as err:
pass
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[./img[@alt='google']][contains(.,'Sign in with Google')]"))).click()
time.sleep(5)
WebDriverWait(driver, 20).until(EC.new_window_is_opened)
driver.switch_to.window([window for window in driver.window_handles if window != original_window][0])
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input#identifierId"))).send_keys(gmail)
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#identifierNext"))).click()
time.sleep(5)
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input[name='Passwd']"))).send_keys(password)
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button/span[.='Next']"))).click()
driver.switch_to.window(original_window)
time.sleep(5)
WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, "//span[.='Full Remake']"))).click()
image_path = r'C:UsersC.LDesktopJonathanc7OgQ1Qh.jpeg'
WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "img[class='object-contain']")))
time.sleep(5)
file_input = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//span[@class='filepond--label-action'][.='Browse']")))
time.sleep(5)
file_input.send_keys(image_path)
How can I upload the image on that website?