Selenium3+Python3_04:iframe切换
1.用iframe的id属性切换到iframe:
driver.switch_to.frame(“id的值”)
2.用iframe的name属性切换到iframe:
driver.switch_to.frame(“name的值”)
3.iframe没有id和name属性,把iframe当作一个对象,用标签去定位全部iframe,然后用下标取某个iframe,再去切换
frame = driver.find_elements_by_tag_name (“iframe”)[0]
driver.switch_to.frame(“frame”)
4.用iframe的索引方式,去切换iframe:
driver.switch_to.frame(0) #索引从0开始
5.切换到上一层:
driver.switch_to.parent_frame()
6.iframe上操作完成,切换回Top Windows:
driver.switch_to.default_content()
实例:126邮箱登陆,切换iframe