I trying to automate a task using Selenium WebDriver
for FireFox on YouTube.
I have a playlist created on YouTube and I want to get the hyperlink of all the videos in that playlist.
The html
looks like this:
<a href="/watch?v=StJLvbPIvTw&list=PLt5xbw4ekDQssXxfaIfh_XbKe-iuOTZo_&index=1" title="ADELE - Skyfall (Official video HD)" class="yt-uix-tile-link yt-uix-sessionlink" data-sessionlink="feature=plpp_video&ei=RodgUazfOKWlhAHOioGoDA">
<span class="title video-title" dir="ltr">ADELE - Skyfall (Official video HD)</span>
</a>
I tried finding the element using the find_by_partial_link_text
but failed.
My ultimate motive is to get the hyperlink for all the videos in the playlist so that i can pass it to next script to access them individually. Any help will be highly appreciated.
Note: I found an answer in SO similar to this SO but the answer provided here is iterating over a WebElement
object which throws an exception in my case saying object is not iterable.
EDIT:
def init():
d = webdriver.Firefox()
d.implicitly_wait(15)
print "in init"
return d
def youtube(d, uname, pwd):
link_list = []
d.get("http://www.youtube.com")
print "in you"
signin = d.find_element_by_partial_link_text("Sign in")
signin.click()
email = d.find_element_by_id("Email")
passwo = d.find_element_by_id("Passwd")
submit = d.find_element_by_id("signIn")
email.send_keys(uname)
passwo.send_keys(pwd)
submit.click()
list = d.find_element_by_partial_link_text("Playlists")
list.click()
play = d.find_element_by_partial_link_text("Fav songs")
play.click()
print play
link_list = d.find_element_by_xpath('//*[@id="playlist-pane-container"]/div[1]')
print "done"
print link_list # prints None here
hr = link_list.get_attribute("css=a@href")
print hr