当前位置:网站首页>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
边栏推荐
- Drop down box for implementation
- Oracle condition, circular statement
- Windows环境Redis使用AOF持久化,无法生成AOF文件,生成后无法加载AOF文件内容
- 容量调度绝对值配置队列使用与避坑
- @Autowired注解为空的原因
- What are the advantages of e-mail marketing? Why do sellers of shopline independent station attach so much importance to it?
- Idea automatically adds comments when creating classes
- 深度學習19種損失函數
- Install redis on windows and permanently change the password, and integrate redis with the SSM framework
- 函数栈帧的创建和销毁
猜你喜欢

移动广告发展动向:撬动存量,精细营销

Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance

JQ picture amplifier

6. graduation design temperature and humidity monitoring system (esp8266 + DHT11 +oled real-time upload temperature and humidity data to the public network server and display the real-time temperature

Sklearn Feature Engineering (summary)

What is webrtc?

Use of JDBC

Slow content advertising: the long-term principle of brand growth

At first glance, I can see several methods used by motionlayout

pytorch详解
随机推荐
PKG package node project (express)
Main functions of 5ggnb and ng ENB
Failed to start component [StandardEngine[Catalina]. StandardHost[localhost]]
pytorch详解
使用SSM框架,配置多个数据库连接
移动广告发展动向:撬动存量,精细营销
Common basic functions of Oracle
Lombok @equalsandhashcode annotation how to make objects The equals () method compares only some attributes
Xcode13.3.1 error reported after pod install
Drop down box for implementation
Syn retransmission caused by IPVS
Deep learning 19 loss functions
JQ picture amplifier
Maskrcnn, fast RCNN, fast RCNN excellent video
函数栈帧的创建和销毁
Yygh-6-wechat login
使用pytorch和tensorflow计算分类模型的混淆矩阵
5g network overall architecture
windows上安装redis并永久修改密码,及ssm框架集成redis
容量调度绝对值配置队列使用与避坑