使用selenium python,我想选择一个iframe
,其中包含以下信息:
<iframe title="Key to fetch simulation results" class="ltiLaunchFrame" name="ltiFrame-1548f8973dbf4d76840c56763e996767" src="/courses/course-v1:EPFL+SimNeuro2+2019_2/xblock/block-v1:EPFL+SimNeuro2+2019_2+type@lti_consumer+block@1548f8973dbf4d76840c56763e996767/handler/lti_launch_handler" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true" allow="microphone *; camera *; midi *; geolocation *; encrypted-media *"></iframe>
我试着去做
webdriver.switch_to.frame("ltiFrame-1548f8973dbf4d76840c56763e996767")'
但是它说
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [name="ltiFrame-1548f8973dbf4d76840c56763e996767"]
但是我用的是正确的名字!我做错了什么
您可以使用上述xpath来定位iframe
代码:
导入:
此外,如果您想从框架中走出来,请使用以下代码:
如果
title
属性值Key to fetch simulation results
是唯一的,则应该这样做:为了使用它,您必须导入
并初始化
wait
对象相关问题 更多 >
编程相关推荐