python - 在 Selenium 中提取隐藏元素

标签 python html selenium captcha recaptcha

我在 iframe 中有一个 hidden 类型的元素。我想知道在我使用 Selenium 时是否有任何方法可以获得这个值。更具体地说,它是一个验证码字段。我试过用

的方式来拉动它
#!/usr/bin/env python

from selenium import webdriver
driver=webdriver.Chrome(chrome_bin_path)
driver.get('http://websitehere.com')
print driver.find_element_by_xpath('//*[@id="recaptcha-token"]').text

但由于它的隐藏性质,它什么也不返回。

以下是源代码的片段。 突出显示的是感兴趣的字符串。 (值(value))

source

最佳答案

driver.switch_to_frame('undefined')
token_value = driver.find_element_by_id('recaptcha-token').get_attribute('value')
driver.switch_to_default_content()

Moving between windows and frames .

关于python - 在 Selenium 中提取隐藏元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38417787/

相关文章:

python - 在 OpenCV 中从桌面获取输入流

javascript - 悬停可拖动的 div 时更改背景

python - 从 Python 中执行不同 where 子句的 SQL

python - 在将这个元组转换为 int 之前,我是否必须将其转换为列表?

jquery - 如何在jquery中获取父级和子级的html

java - TestNG 自定义报告器 - 添加堆栈跟踪到报告

python - 如何避免每次使用 Selenium 和 Python 时都出现 Instagram 登录页面

java - 如何使用 Selenium JavascriptExecutor 将 <script> 添加到 Head 中

python - 如何使用Docker连接Jupyter Notebook

css - 图像对 Max-Width 属性没有反应