测一个登录功能的时候,死活无法直接定位到元素,查看源代码发现存在一个嵌入的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")
版权声明:本文为博主原创文章,未经博主允许不得转载。
已抢140774个
抢已抢4584个
抢已抢7082个
抢已抢11568个
抢