[英]Accessing this value from a website using the selenium library in python
I was able to use selenium to create a driver, and use it to login to this site and load this page我能够使用 selenium 创建驱动程序,并使用它登录到该站点并加载此页面
How should I go about trying to access this 2.8 ± 0.5 value?我应该如何尝试访问这个 2.8 ± 0.5 值? I was able to access the
<iframe>
by using我能够通过使用访问
<iframe>
iframe = WebDriverWait(driver, timeout=10).until(EC.presence_of_all_element_located((By.TAG_NAME,'iframe')))
but then when I did但是当我这样做的时候
iframe.find_element(By.CLASS_NAME,'src')))
I couldn't get anything.我什么也得不到。
Is there any workaround for how to get this value?是否有任何解决方法来获取此值? Should I try to go to the src link first?
我应该先尝试去 src 链接吗? Is selenium the correct library to attempt this?
selenium 是尝试这个的正确库吗? Thank you.
谢谢你。
You need to switch to the <iframe>
before locating elements under it.您需要先切换到
<iframe>
,然后再在其下定位元素。 You can use frame_to_be_available_and_switch_to_it
for that您可以为此使用
frame_to_be_available_and_switch_to_it
WebDriverWait(driver, timeout=10).until(EC.frame_to_be_available_and_switch_to_it((By.TAG_NAME,'iframe')))
You can also use the id
or name
attributes without By
您也可以使用不带
By
的id
或name
属性
WebDriverWait(driver, timeout=10).until(EC.frame_to_be_available_and_switch_to_it('MLVALUEDFT_dielectric_total'))
And now use driver.find_element(...)
to locate the element.现在使用
driver.find_element(...)
来定位元素。
To switch back out of the <iframe>
use driver.switch_to.default_content()
要退出
<iframe>
使用driver.switch_to.default_content()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.