Python Selenium switch into an iframe within an iframe -
I have an iframe inside using an iframe Selenium, Python, and BS4
selenium imports webdriver import time import html5lib drivers BS4 import = webdriver.Firefox (from BeautifulSoup) driver.implicitly_wait (10) driver.get ( 'http://myurl.com') : time.sleep (4) iframe = driver.find_elements_by_tag_name ( 'iframe') [0] driver.switch_to_default_content () driver.switch_to_frame (iFrame) driver.switch_to_default_content () driver.find_elements_by_tag_name ( 'iframe') [0] output = driver .page_source print output at the end: driver.qu It (); Within the returned text, two more iframes seem to get me how do I reach them? I have tried in the above code without success.
Any help is appreciated.
switch_to_default_content () you will return to the top of the document. What's happening is that you have already changed to iframe , went back to the top of the document, then tried to find another iframe . Because it is the first iframe inside .
If you second Retrieve switch_to_default_content () iframe can not find , / code> you should be fine:
< code> iframe = driver.find_elements_by_tag_name ( 'iframe') [0] driver.switch_to_default_content () driver.switch_to_frame (iFrame) driver.find_elements_by_tag_name ( 'iframe') [0] < / Html>
Comments
Post a Comment