【发布时间】:2017-05-30 04:40:18
【问题描述】:
我处理的页面有不可见的隐藏选项按钮。
* download sample video in the page(button is hidden by html)
[button1] (<- LINK_TEXT i s 'button1')
[button2]
[button3]
所以,我使用了“EC.element_to_be_clickable”。 此代码有效,但如果我不知道按钮的 LINK_TEXT,则不能使用这种方式。每个页面的 LINK_TEXT 名称都不同。
我只想获取视频的第一个链接 url(ex-button1)。
_sDriver = webdriver.Firefox()
_sDriver.get('www.example.com/video')
wait = WebDriverWait(_sDriver, 10)
download_menu = _sDriver.find_element_by_id("download-button")
action = ActionChains(_sDriver)
action.move_to_element(download_menu).perform()
documents_url = wait.until(EC.element_to_be_clickable((By.LINK_TEXT, "button1"))).get_attribute('href')
我的代码结果是通过 'button1' 的 url 获得的,但是如果我不知道 'button1' 文本,如何使用 python 获取第一个隐藏按钮的 url?
感谢您的帮助。
【问题讨论】:
标签: python selenium selenium-webdriver hidden-field