iframe

一、frame:HTML页面中的一种框架,主要作用是在当前页面中指定区域显示另一页面元素;

 

二、操作Frame中的页面元素

定位元素:

1.id定位
driver.switch_to.frame('frame_id')

2.name定位
driver.switch_to.frame('frame_name')

3.索引
driver.switch_to.frame(0)

4.webelement对象
a=driver.find_element_by_xpath('//iframe')
driver.switch_to_frame(a)

 

嵌套frame

1.fame1中嵌套frame2:
先切换到frame1,再切换到frame2
driver.switch_to.frame('frame1')
driver.switch_to.frame('frame2')

2.从frame2返回到frame1
driver.switch_to.parent_frame()

3.回退到主文档
driver.switch_to.default_content()

相关文章:

  • 2022-12-23
  • 2019-06-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-27
  • 2021-09-15
  • 2021-03-26
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案