python3+selenium3自动化3——iframe

一、frame 和 iframe 的区别

  1、frame 不能脱离 frameset 单独使用,iframe 可以;
  2、frame 不能放到body中,否则将无法显示;
  3、iframe 也可以嵌套在frameset ,但是必须放到body中,不嵌套在frameset 中的iframe 可以随意使用;
  4、frame 的高度只能通过 frameset 控制,iframe 是自己本身控制,不能通过 frameset 设置;
  5、iframe 可以放到表格中;

二、如果iframe的id为动态id怎么定位

    如果id为动态id,可以相当于iframe没有id元素,用其他元素定位

三、iframe定位元素

    切换iframe:driver.switch_to_frame
    退出iframe:driver.switch_to_default_content  
    如何切换多少iframe
            driver.switch_to_frame('f1')
            driver.switch_to_default_content  
            driver.switch_to_frame('f2')
    嵌套iframe如何切换
            driver.switch_to_frame('f1')
            driver.switch_to_frame('f2')
            driver.switch_to.parent_farme()    # 回到F1
            driver.switch_to.default_content()        # 跳出ifarme,回到主页面
原文地址:https://www.cnblogs.com/jiliangceshi/p/12768094.html