Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python selenium get inside a #document

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>
like image 558
gustavo serna Avatar asked Dec 25 '22 03:12

gustavo serna


1 Answers

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")
like image 142
Yu Zhang Avatar answered Dec 26 '22 16:12

Yu Zhang