#案例:处理ifame框架!
from selenium import webdriver # 导入webdriver包
import time
driver=webdriver.Chrome()
driver.maximize_window() # 最大化浏览器
driver.implicitly_wait(30)
driver.get("http://oss.52studyit.net/webzdh/zucesili.html") # 通过get()方法,打开一个url站点
driver.find_element_by_id("user").send_keys("张三")
eles_frame=driver.find_elements_by_css_selector("iframe")
#切换到注册A:iframe框架中
# driver.switch_to.frame("idframe1")
driver.switch_to.frame(eles_frame[0])
driver.find_element_by_id("userA").send_keys("张三A")
#回到默认
driver.switch_to.default_content()
#切换到注册B
# driver.switch_to.frame("myframe2")
driver.switch_to.frame(eles_frame[1])
driver.find_element_by_id("userB").send_keys("张三B")
driver.switch_to.default_content()
time.sleep(5)
driver.quit() # 关闭并退出浏览器