Python selenium get inside a #document

百般思念 提交于 2019-12-22 08:35:15

问题


How can I keep looking for elements in a #document:

<div>
    <iframe>
        #document
            <html>
               <body>
                   <div>
                        Element I want to find  
                   </div>
               </body>
            </html>
    </iframe>
</div>

回答1:


I think your problem is not with the a#document but with iframe.

from selenium import webdriver

driver = webdriver.Firefox()
iframe = driver.find_elements_by_tag_name('iframe')[0]
driver.switch_to_frame(iframe)

driver.find_element_by_xpath("//div")


来源:https://stackoverflow.com/questions/38363643/python-selenium-get-inside-a-document

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!