0

I am trying to upload files to a website, that has a drop box area to upload files, I tried element.click() and it shows windows pop up to choose file, and when I tried element.send_keys('path') it raise Message: element not interactable, how to approach this problem.

here is the website: http://shareclips.net

Thanks in advance.

asked Mar 2, 2021 at 14:11

1 Answer 1

1

Upload input control opens a native dialog (it is done by browser) so clicking on the control or browse button via Selenium will just pop the dialog and the test will hang.

The workaround is to set the value of the upload input via JavaScript and then submit the form.

// simulate click
webdriver.ActionChains(driver).move_to_element(element).click(element).perform()
// driver is instance of webdriver
driver.find_element_by_id("IdOfInputTypeFile").send_keys(os.getcwd()+"/video.mp4")

os.getcwd() returns the current working directory. video.mp4 is located right next to the running script in the same directory.

answered Mar 2, 2021 at 14:15

9 Comments

Thanks for the suggestion, i have tried it like this driver.find_element_by_id("uploader-block").send_keys(os.getcwd()+"videos/video.mp4") because i have the videos in a directory named 'videos' and still get the same error element interactable.
I think selenium is not finding the element try time.sleep(10)
yeah even after the time.sleep(10) still interactable.
I found it, you need to click the element via Javascript as opposed to a "natural" click that selenium uses (to try to simulate the user experience). so check out my updated answer.
hmm i dont know what am i doing wrong, i created element = driver.find_elemnt_by_id("upload-clickable") and same error
|

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.