Unable to close file upload window

258 views
Skip to first unread message

Muhammad Junaid Raza

unread,
Mar 7, 2024, 9:21:19 AM3/7/24
to Selenium Users
Hi
I am tryin to upload a file, I can pass the path and can press the UPLOAD button but then it is stuck and not closing to go back to previous window to update. 
Even if I try manually by using mouse to close or even cancel the window, it doesn't work, tried both in Edge and Google with no luck

I'm using below to get the file path

Webdriver = driver.FindElement(By.XPath("//input[@type='file']"))
Webdriver.SendKeys("C:\Users\myuser\Desktop\aarf.pdf")

Then below to click UPLOAD so that it closes

Threading.Thread.Sleep(2000)
Webdriver = driver.FindElement(By.XPath("//button[@id='uploadFile']/span"))
Threading.Thread.Sleep(6000)
Webdriver.Click()

But it gets stuck, UPLOAD is pressed but then nothing happens

Untitled.png

Adrian

unread,
Mar 7, 2024, 3:06:15 PM3/7/24
to Selenium Users
Hi,
For these situations I would be talking to your developers to try and find out what the issue is.
It seems to be something with the user interface rather than a selenium issue.

Cheers,
Adrian.

Muhammad Junaid Raza

unread,
Mar 9, 2024, 12:33:34 PM3/9/24
to Selenium Users
Hi Adrian,
Thanks for replying, actually if we use the UI, there is no issue, user can click 'Upload files' in the image above in the back end, it opens file dialogue, user clicks  browse, select file then click Upload and this dialogue closes.
But with selenium, I can reach up to the point of loading file and click 'UPLOAD' it get clicked and then becomes stuck.
Shall I try by passing file path to file dialogue then close it somehow and then try UPLOAD?
Thanks

Adrian

unread,
Mar 11, 2024, 6:06:49 AM3/11/24
to Selenium Users
No it will work without the file dialog, as selenium can't interact with that (Windows) dialog.
That's why I would ask a developer about what is wrong.  It might be that there is more than 1 file input element and you are using the wrong one.  That is an issue I had. 
I figured out the correct file input element by trial and error, as I had 3 of them.
Reply all
Reply to author
Forward
0 new messages