Can't figure it out how upload the file there? It needs to be drag and dropped or just selected via dialog box
4 Answers
"Looks like you cannot upload files on YouTube using the typical sendkeys method"
4 years later...
@chandan-nayak: You can, here's a python solution to upload a video to YouTube using selenium:
from selenium import webdriver
driver = webdriver.Firefox()
driver.implicitly_wait(5) # Wait up to 5 secs before throwing an error if selenium cannot find the element (!important)
driver.get("https://www.youtube.com/upload")
elem = driver.find_element_by_xpath("//input[@type='file']")
elem.send_keys("C:\\full\\path\to\\video.mp4"); # Window$
#elem.send_keys("/full/path/to/video.mp4"); # Linux
Notes:
1 - Be smart, go slowly but surely;
2 - YouTube max uploads per day is 50, but on the first day is 100;
3 - As of 2019, youtube api is limited to 5 video uploads per day(◔ _◔)
6 Comments
Elem.send_keys("C:\\first.mp4","C:\\second.mp4") this does not workAs per the answer here on: stackoverflow Looks like you cannot upload files on YouTube using the typical sendkeys method.
as @Arran said there in the comment section -
Selenium cannot handle file upload dialogs. YouTube uses HTML5 input fields, and Selenium doesn't handle HTML5 elements even in the slightest. As I said, Selenium cannot support this. Selenium won't work here
You shall use the API provided by youtube
Comments
5 years later...
I run into the same issue and found youtube-uploader-selenium package.
As of 2019, youtube api is limited to 5 video uploads per day(◔ _◔)
The description says
Instead, this script is only restricted by a daily upload limit for a channel on YouTube: 100 videos is the limit in the first 24 hours, then drops to 50 every 24 hours after that.
Comments
you may need this give it a shot ytb_up based selenium
https://github.com/wanghaisheng/ytb-up features YOU MAY NEED
- proxy support
auto detect whether need a proxy 2. cookie support
for those multiple channels under same google account 3. schedule time publish
you can explictly specify a date and time for each video or you can set publish policy and daily public count,for example,daily count is 4,you got 5 videos,then first 4 will be published 1 day after the upload date ,the other 1 will be 2 days after the upload date 4. fix google account verify