当前位置:网站首页>Iframe switching in Web Automation
Iframe switching in Web Automation
2022-06-28 06:06:00 【FamilyYan】
One 、iframe Switch mode
1、 adopt iframe Of name attribute
Premise is iframe Yes name attribute
driver.switch_to.frame("login_frame")
2、 Locate by element
iframe = driver.find_element(By.ID, "login_frame")
driver.switch_to.frame(iframe)
driver.find_element(driver.find_element(By.ID, "login_frame"))
3、 Index access
iframes = driver.find_elements_by_tag_name("iframe")
driver.switch_to.frame(1)
driver.switch_to.frame(driver.find_elements_by_tag_name("iframe")[1])
other :
1、 Switch to parent's iframe :driver.switch_to.parent_frame()
2、 Switch to the topmost iframe:driver.switch_to.default_content()
Two 、 Code implementation
visit QQ Mailbox as an example :
from selenium import webdriver
import logging
import time
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
logging.basicConfig(level=logging.DEBUG)
# Start the browser driver server
driver = webdriver.Chrome()
driver.get("https://mail.qq.com/")
driver.maximize_window()
# cut iframe, adopt name Property Toggle
driver.switch_to.frame("login_frame")
# Navigate to the account input box
locator2 = (By.XPATH, '//input[@id="u"]')
ele2 = WebDriverWait(driver=driver, timeout=10, poll_frequency=1).until(
EC.visibility_of_element_located(locator=locator2))
ele2.send_keys("[email protected]")
time.sleep(5)
driver.quit()
Running effect :
open QQ mailbox , Input QQ account number
边栏推荐
- Filecoin hacker song developer competition
- Configure multiple database connections using the SSM framework
- 简单手写debounce函数
- 5g network overall architecture
- Yolact++ Pytorch环境
- Apple MDM bypass jailfree bypass MDM configuration lock free
- Yygh-7-user management
- mac下安装多个版本php并且进行管理
- 阿里云短信服务(完整指南),短信发送功能实现。
- Xcode13.3.1 项目执行pod install后报错
猜你喜欢
随机推荐
使用SSM框架,配置多个数据库连接
慢内容广告:品牌增长的长线主义
Apple MDM Bypass 免越狱绕过MDM配置锁 免费
重载,重写的区别,抽象类,接口的区别
Yolact++ Pytorch环境
链表(一)——移除链表元素
Relevant implementation records of CSI and local disk
EasyUI reset multi condition query
【无标题】
Configure multiple database connections using the SSM framework
基本类型和包装类的区别
Development trend of mobile advertising: Leveraging stock and fine marketing
ipvs 导致syn 重传问题
pytorch dataloader的长度 epoch与iteration的区别
Yygh-7-user management
链表(二)——设计链表
lombok @EqualsAndHashCode 注解如何让对象.equals()方法只比较部分属性
Differences between basic types and packaging classes
High quality domestic stereo codec cjc8988, pin to pin replaces wm8988
Configure redis from 0