当前位置:Gxlcms > html代码 > Webdriver处理嵌入的iframe_html/css_WEB-ITnose

Webdriver处理嵌入的iframe_html/css_WEB-ITnose

时间:2021-07-01 10:21:17 帮助过:18人阅读

测一个登录功能的时候,死活无法直接定位到元素,查看源代码发现存在一个嵌入的iframe,而我需要定位的元素正好在嵌入的iframe中

解决办法:
先定位到这个iframe,切换到这个iframe,然后再在ifame中取元素

loginFrame = self.driver.find_element_by_xpath("//iframe[@allowtransparency='true']")self.driver.switch_to.frame(loginFrame)self.driver.find_element_by_name("username")

版权声明:本文为博主原创文章,未经博主允许不得转载。

人气教程排行