公告
财富商城
积分规则
提问
发文
2020-01-24 13:05发布
smile是对你的礼貌
How would I switch to this iframe in selenium knowing only
<iframe name="Dialogue Window">
As the iframe tag clearly shows the name as Dialogue Window, so here is the simple & minimal line of code to switch to the iframe:
iframe
Dialogue Window
As the <iframe> contains the name attribute you can :
<iframe>
name
driver.switch_to.frame("Dialogue Window")
As an alternative you can switch with respect to the WebElement as follows :
WebElement
driver.switch_to.frame(driver.find_element_by_name('Dialogue Window'))
To switch back to the Top Window you can use the following line of code:
Top Window
driver.switch_to.default_content()
You can use an XPath to locate the <iframe>:
iframe = driver.find_element_by_xpath("//iframe[@name='Dialogue Window']")
Then switch_to the <iframe>:
switch_to
driver.switch_to.frame(iframe)
Here's how to switch back to the default content (out of the <iframe>):
最多设置5个标签!
As the
iframe
tag clearly shows the name asDialogue Window
, so here is the simple & minimal line of code to switch to the iframe:As the
<iframe>
contains thename
attribute you can :As an alternative you can switch with respect to the
WebElement
as follows :To switch back to the
Top Window
you can use the following line of code:You can use an XPath to locate the
<iframe>
:Then
switch_to
the<iframe>
:Here's how to switch back to the default content (out of the
<iframe>
):