kaliiiiiiiiii / Selenium-Driverless

undetected Selenium without usage of chromedriver
https://kaliiiiiiiiii.github.io/Selenium-Driverless/
Other
412 stars 52 forks source link

cant send file to upload #248

Closed miltonvo closed 1 week ago

miltonvo commented 1 week ago

im trying to use send_keys or write but nothing send file to upload:

image_path = os.path.join(image_dir, image_files[image_index])
logger.debug(f"selecting photo: {image_path}")
file_inputs = await self.driver.find_element(By.CSS_SELECTOR, "input[type='file']")
await file_input.send_keys(image_path)

I find the visible element, but the file selection window in Windows remains open and without sending the file i tried to send file with javascript but got this error:

await self.driver.execute_script("arguments[0].style.display = 'block'; arguments[0].style.visibility = 'visible';", file_input)
await self.driver.execute_script("arguments[0].value = arguments[1];", file_input, image_path)
 DOMException: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string.
    at <anonymous>:4:40
kaliiiiiiiiii commented 1 week ago

This is verry well documented - please ALWAYS have a look at the documentation first

kaliiiiiiiiii commented 1 week ago

see WebELement.set_files