I have a script that uploads a file on XenForo forum.
The script works fine on mac and linux but seems to just get stuck on infinite loop of trying to upload the file when run on windows.
Running Info.
Windows 11
Firefox 129.0.2 (64-bit)
geckodriver v0.35.0-win32 - 64 bit version give me error OSError: [WinError 216] This version of %1 is not compatible with the version of Windows you're running. Check your computer's system information and then contact the software publisher
I tired using the same version of firefox and geckodriver on linux and it works fine.
here is the segment of code the issue is occuring on.
while 1:
try:
e = driver.find_element(By.CSS_SELECTOR, "input[type='file']")
upload_file = f"{meta['base_dir']}/tmp/{meta['uuid']}/{meta['clean_name']}.txt"
print(e)
print(upload_file)
e.send_keys(upload_file)
break
except:
print(Error Uploading file)
The script is pretty basic in that it just selects a file and uploads it. I added the print statements but unsure how else to debug. I assume the issue is path related since windows handles paths differently but i tried a few things with no luck.
It seems to be finding the upload selector but file is not being selected when i run NON headless.
<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="cd69ff4f-2cd1-4087-bf92-e43976ff43bd", element="f6e36a8e-533c-4ebf-96cf-055826c73933")>
C:\Users\username\Desktop\files/tmp/asda1213sdfa/27082024.txt
Any help would be appreciated.
Make sure you use backslashes for Windows file paths.
Edit:
upload_file = f"{meta['base_dir']}\\tmp\\{meta['uuid']}\\{meta['clean_name']}.txt"
See this SO answer for more detail.