There is a known issue with file upload input has CSS display=none.
This causing WebUI.uploadFile… to fail.
There are 3 common solutions for handling this scenario.
Implement WebDriver methods.
Tried this same issue as when using WebUI.uploadFile
Tried this and application under test crashed with “unexpected error” message
Handle Modal upload windows with Java Robot.
Worked great, but when executing from Jenkins there is no visible browser running. Therefore it modal window wasn’t executed.
What can you recommend?
Also, is it possible to see the browser session when running scripts from command line?
The provided solution worked. Having visible browser allowed us to debug scripts against CI environment.
There were environment configuration differences between developer and CI machines.
This also solved the issue with overwriting CSS at run time. Therefore, both CSS overwrite and Java Robot are valid alternative solutions for handling hidden file upload input .
WebDriver driver = DriverFactory.getWebDriver();
StringSelection s = new StringSelection(filePath);
Robot robot = new Robot();
For the third solution using Java Robot and you are having issues with Jenkins, you should prefer to the solution provided from this
page. Said in another way
I Tried using Java Robot but the flow gets stuck at the point where the file has to be chosen at the Folder structure.
My file location is at say: /Users/xxxx/Documents/Katalon\ Studio/xxxx/Include/testFiles/img.png
The control is lost after going to : /Users/xxxx
How can i perform further operation? Please help