首页 > 技术文章 > 使用python处理selenium中的frame切换问题

sgwjj 2017-12-13 15:23 原文

# iframe有name或id值

self.driver.switch_to.frame('iframe-name-id')

# iframe没有name或id值

xf = self.driver.find_element_by_xpath('//iframe[@allowtransparency="true"]')

self.driver.switch_to.frame(xf)

# 跳出当前iframe

self.driver.switch_to.parent_frame()

# 返回最外层iframe

self.driver.switch_to.default_content()

推荐阅读