web自动化4-selenium基本操作iframe

如果元素定位不上,确定是否有iframe

切换到iframe页面,再次进行定位

 

Id

driver.switch_to_frame(“id”)

 

name

driver.switch_to_frame(“name”)

 

无id、name

iframe = driver.find_element_by_tag_name(“iframe”)

driver.switch_to_frame(iframe)

 

iframe = driver.find_element_by_xpath(“//*[@name=’wd’”)

driver.switch_to_frame(iframe)

# 释放iframe,重新回到主页面上

driver.switch_to.default_content()

posted on 2017-09-22 23:13  zhangjason  阅读(321)  评论(0)    收藏  举报

导航