Hi, are you sure there is no hidden inupt field activated afer the click on “upload” button? Maybe the solution would be to disable native win window. Thread below delivers solution. For browser(PW) library you just need to use Execute Javascript, but works alos for Se.
Trying the same with PyAutoGui
Seeing “Importing test library ‘PyAutoGUI’ failed: ModuleNotFoundError: No module named ‘PyAutoGUI’”
I have installed and imported the PyAutoGui library in the testcase. Please let me know if i have missed anything
MouseInfo 0.1.3
pillow 10.2.0
pip 20.2.1
PyAutoGUI 0.9.54
pycparser 2.20
PyGetWindow 0.0.9
PyMsgBox 1.0.9
PyNaCl 1.5.0
pyperclip 1.9.0
PyRect 0.2.0
PyScreeze 1.0.1
PySocks 1.7.1
python3-xlib 0.15
pytweening 1.2.0
robotframework 6.1.1
robotframework-pythonlibcore 2.1.0
robotframework-seleniumlibrary 4.5.0
selenium 3.141.0
setuptools 49.2.1
six 1.15.0
urllib3 1.25.11
Some cases, specifically those where user is expected to “drop and drop” the file do not have a specified input tag for fileupload.
SeleniumTestability does have keyword that does following:
create hidden input field into a form at the time keyword is called.
“uploads the file” into form
Simulates the drag and drop event so that the frontend code can work similarry as user would have dragged the file from operating system into the browser element that handles incoming drop and drop event…
removes the hidden input field.
With the caveat that ST probably is not fully working, maybe try it it … Or copy the relevant parts off?
Not a hard requirement, sadly Any element can have event listeners to accept drag and drop events that can then be used to upload a file to backend. One notable js framework that does this; https://www.dropzone.dev/
After debugging the PyAutoGUI error, I found that the package was not installing in the virtual environment but instead in ~/.local/lib/python3.8/site-packages, which caused the issue. And i dont have the permission to install the PyAutoGUI in virtual env
what would be the best solution to fix this and proceed with PyAutoGUI, or using JavaScript instead?
I’d suggest poking around the html source with devtools and also check the network tab of devtools, find the call when the file is being uploaded and try to figure out how the page actually uploads the file.
If there’s no file <input>, then it’s most likely being done with Javascript, so if you can figure out which JS function, then hopefully you can call it with Execute Javascript or Evaluate JavaScript (depending which library you’re using.
I’ll note a hidden file input is the most common approach, I’ve only seen 1 application that did file uploads with pure Javascript and no file input, but once you know how the page does it in the browser, you’re 1/2 way to figuring out how to automate it.