码迷,mamicode.com
首页 > 其他好文 > 详细

selenium定位当前处于那个iframe(frame)中

时间:2019-10-17 13:58:54      阅读:365      评论:0      收藏:0      [点我收藏+]

标签:获取   htm   多个   http   inf   iframe   img   style   span   

问题:操作某元素时,总是定位不上,此时需要确认你在哪个iframe里。

如图html代码,有很多个iframe,代码如下

技术图片

 

定位问题的代码:

获取当前iframe的tag name,确定有几个iframe,你所在的元素和获取到页面的iframe之间的关系,来进行iframe的切换。

for child_frame in driver.find_elements_by_tag_name("iframe"):
    child_frame_id = child_frame.get_attribute("src")
    print(child_frame_id)

  

 

selenium定位当前处于那个iframe(frame)中

标签:获取   htm   多个   http   inf   iframe   img   style   span   

原文地址:https://www.cnblogs.com/bubutianshu/p/11691186.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!