xxxxxxxxxx
# switching to second iframe based on index
iframe = driver.find_elements(By.TAG_NAME,'iframe')[1]
# switch to selected iframe
driver.switch_to.frame(iframe)
xxxxxxxxxx
# switch back to default content
driver.switch_to.default_content()
xxxxxxxxxx
# Store iframe web element
iframe = driver.find_element(By.CSS_SELECTOR, "#modal > iframe")
# switch to selected iframe
driver.switch_to.frame(iframe)
# Now click on button
driver.find_element(By.TAG_NAME, 'button').click()