Webdriver处理嵌入的iframe_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:35:26
Original
1236 people have browsed it

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

<iframe allowtransparency="true" src="https://account.xxx.com/#/login/embed?origin=http://test.xxx.com" frameborder="0" style="display: block;"></iframe>
Copy after login

解决办法:
先定位到这个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")
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!