当前位置:网站首页>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
边栏推荐
猜你喜欢

高质量国产立体声编解码器CJC8988,Pin to Pin替代WM8988

异常处理(一)——空指针和数组索引越界

基于Kotlin+JetPack实现的MVVM框架的示例

深度學習19種損失函數

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

High quality domestic stereo codec cjc8988, pin to pin replaces wm8988

Filecoin hacker song developer competition

YYGH-BUG-02

Independent station sellers are using the five e-mail marketing skills, do you know?

Working principle of es9023 audio decoding chip
随机推荐
Working principle of es9023 audio decoding chip
Official answers to the "network security" competition questions of the 2022 national vocational college skills competition
Install fmpefg
Windows环境Redis使用AOF持久化,无法生成AOF文件,生成后无法加载AOF文件内容
How to add live chat in your Shopify store?
Install redis on windows and permanently change the password, and integrate redis with the SSM framework
Install and manage multiple versions of PHP under mac
Lombok @equalsandhashcode annotation how to make objects The equals () method compares only some attributes
Ape pink ape power - Developer activity attack!
pytorch详解
easyui 重置多条件查询
death_satan/hyperf-validate
Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
What are the advantages of e-mail marketing? Why do sellers of shopline independent station attach so much importance to it?
Sharing tips for efficient scripting
函数栈帧的创建和销毁
Capacity scheduling absolute value configuration queue usage and pit avoidance
CSI以及本地盘的相关实现记录
mac下安装多个版本php并且进行管理
不会还有人只会用forEach遍历数组吧?