web自动化-iframe切换

1、切换到指定的iframe

      driver.switch_to.frame() #支持3种方式来确定切换到哪一个iframe

  1)iframe下标,编号从0开始,driver.switch_to.frame(3) 

  2)iframe元素的name或id属性  driver.switch_to.frame(“name属性值”) 

  3)iframe的webelement元素 driver.switch_to.frame(driver.find_element_by_xpath("XPATH路径"))

2、退出iframe回到默认的html

        driver.switch_to.default_content()

3、回到上一级的iframe

  driver.switch_to.parent_frame()

猜你喜欢

转载自www.cnblogs.com/surea/p/12423099.html