[英]Extracting hidden element in Selenium
我在iframe中hidden
了类型的元素。 我想知道是否有任何方法可以像我使用硒那样获得此值。 更具体地说,它是一个验证码字段。 我尝试过用类似的方法拉它
#!/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
但是由于它的隐藏性质,它什么也不返回。
以下是源代码片段。 突出显示的是感兴趣的字符串。 (值)
driver.switch_to_frame('undefined')
token_value = driver.find_element_by_id('recaptcha-token').get_attribute('value')
driver.switch_to_default_content()
使用这个方法
hidden_text = element.get_attribute("textContent")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.