I want to get a "data-href" link from a button. I have used Selenium.I can successfully enter in my desired page but when I am trying to get the link from the button nothing happen,but throws an exception selenium.common.exceptions.NoSuchElementException: I don't have any idea where I am going wrong. my HTML:
<div class="lecture-attachment lecture-attachment-type-audio"
id="lecture-attachment-7274677">
<div class="attachment-data"></div>
<div class="audioloader" data-audioloader="AttachmentDrop" data-
audioloader-name="ESLPod1103.mp3" data-audioloader-type="audio/mpeg"
data-audioloader-
url="https://www.filepicker.io/api/file/Ius016cNTJmPRjUuCCp7" data-
audioloader-initialized="true">
<div class="audioloader__placeholder">
<button data-
href="https://www.filepicker.io/api/file/Ius016cNTJmPRjUuCCp7"
target="_blank" style="
border: 0;
outline: 0;
background: transparent;
cursor: pointer;
">
<span class="audioloader__icon glyphicon glyphicon-play"></span>
<span class="audioloader__name">ESLPod1103.mp3</span>
</button>
</div>
</div>
</div>
Python code
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException, \
WebDriverException
driver = webdriver.Chrome(executable_path='/Users/lmuser/chromedriver')
driver.get ("https://sso.teachable.com/secure/147717/users/sign_in?
clean_login=true&reset_purchase_session=1")
driver.find_element_by_id("user_email").send_keys("***")
driver.find_element_by_id("user_password").send_keys("***")
driver.find_element_by_name("commit").click()
driver.get("https://tv.eslpod.com/courses/239156/lectures/3732329")
for i in driver.find_elements_by_xpath('//*[@id="lecture-attachment-
7274677"]/div[2]/div/button'):
print(i.get_attribute("data-href"))