driver .switch_to.frame()
转到内部frame
driver .switch_to.default_content()
转回默认
elment别加S,先定位到Iframe,然后在切换
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('https://mail.163.com/')
iframe = driver.find_element_by_xpath('/html/body/div[2]/div[3]/div[1]/div/div[4]/div[1]/div[1]/iframe')
driver.switch_to.frame(iframe)
driver.find_element_by_name('email').send_keys('15927561940')
登录成功后想要写邮件先退出Iframe否则无法元素定位
self.driver.switch_to.default_content()
在robotframework中有Iframe框架,首先用xPATH定位到iframe是个好主意
例如126邮箱 记得步骤间加等待时间否则读取不到XPATH
Select Frame xpath=/html/body/div[2]/div[3]/div[1]/div/div[4]/div[1]/div[1]/iframe