I'm trying to switch the Selenium 'focus' to the contents inside of an iframe that's inside of another iframe. My selenium test below seems to work so far. However, there is another iframe within that iframe that I want to get- but I'm not sure now.
Here is the markup (second iframe highlighted):
This is my test so far (which works- just not sure how to get the second iframe within the first iframe):
import unittest
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec
from .functional_test import FunctionalTest
class MyTest(FunctionalTest):
URL = '/datastory/my-datastory/'
@classmethod
def setUpClass(cls):
"""Set up method."""
super().setUpClass()
cls.URL = cls.format_url(cls.URL)
cls.login_user(cls)
def test_iframe(self):
container = self.browser.find_element_by_id('visual-31')
carousel = container.find_element_by_css_selector('.col-sm-12:nth-child(2) div.visual #classics-50-carousel')
wait = WebDriverWait(self.browser, 60)
wait.until(ec.visibility_of(carousel))
page_source = carousel.get_attribute("src");
self.assertEqual(
page_source,
'https://observablehq.com/embed/@ddsg/paramount-databyte-visuals?cells=classics50yrs'
)
# switch Selenium focus to the iframe
iframe = self.browser.switch_to.frame(carousel);
#NOW HOW DO I GET THE OTHER IFRAME??
# switch back
self.browser.switch_to.default_content()