通过Selenium和python切换到iframe [英] Switch to an iframe through Selenium and python

查看:143
本文介绍了通过Selenium和python切换到iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何仅凭硒切换到iframe中的

How would I switch to this iframe in selenium knowing only

<iframe name="Dialogue Window">

推荐答案

您可以使用XPath来找到<iframe>:

You can use an XPath to locate the <iframe>:

iframe = driver.find_element_by_xpath("//iframe[@name='Dialogue Window']")

然后switch_to <iframe>:

driver.switch_to.frame(iframe)


以下是切换回默认内容(<iframe>中的内容)的方法:


Here's how to switch back to the default content (out of the <iframe>):

driver.switch_to.default_content()

这篇关于通过Selenium和python切换到iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆