0

I trying to upload video file with selenium, it doesn't work

my code:

a = wait.until(EC.element_to_be_clickable((By.TAG_NAME, 'input'))) browser.execute_script("arguments[0].style.visibility = 'visible'", a) a.send_keys("C:/Users/NIKITA/Desktop/vk_clips/testvid.mp4")

enter image description here

This script works but doesn't load the file and doesn't throw an error. I tried searching for the element using XPath, it causes a timeout exception.

1 Answer 1

0

The web element actually accepting the uploaded file is matching this XPath: "//input[@type='file']". This element is not visible. You can see yourself on picture you shared visibility: hidden.
Again, this is not an element you clicking when uploading file manually as a user via the GUI.
So, to upload file to it you can not wait for it to become visible or clickable.
Just wait for this element presence.
Your code can be something like the following:

wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@type='file']"))).send_keys("C:/Users/NIKITA/Desktop/vk_clips/testvid.mp4")
Sign up to request clarification or add additional context in comments.

2 Comments

Is there any way I can make the element visible?
No. And you should not. Selenium imitates human actions on the web page. This element is not visible by human user. It receives the uploaded file internally when you clicking the upload button on the presented menu. But with Selenium we can do this action directly. Not good enough?

Your Answer

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.