I am writing a simple Python script that goes on a website (with Selenium) and upload a file on the website. I'm using PyAutoGUI to enter the filename and press "Enter" because the website doesn't use an input
.
driver.get("https://website_url.com/upload/")
elm = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CLASS_NAME, "file_Picker")))
driver.find_element(By.CLASS_NAME, "file_Picker").click()
pyautogui.write("C:\\Users\\Lulucmy\\PythonProject\\test.png")
pyautogui.press('enter')
time.sleep(2)
The issue is that each time PyAutoGUI write on the upload window, the colon is replaced by a slash :
C/\\Users\\Lulucmy\\PythonProject\\test.png
What I've tried :
- Replacing pyautogui.write by pyautogui.typewrite
- Using pyautogui.press(':') and dividing the file path in two parts
I think the issue comes from the keyboard layout, but I couldn't find how to change it on PyAutoGUI. Also, if you could think of a solution without using PyAutoGUI I'd be glad to know it.
Thank you for your help!