I\'m working on a page with nested frames, and am unable to access a child frame. Brief outline of HTML source:
Try this:
driver.switch_to_frame("name")
driver.switch_to_frame("mid2")
The issue you're running into is that javascript can only work with the current frame it sees. mid2
is in a child frame it cannot see if you're at the top of the document.
The <frame>
tag with name
as mid2 seems to be nested within 2 additional layers of <frame>
.
to access the <frame>
with name
attribute as mid2 you have to:
<frameset>
tags.<frame>
to be available and switch to it.<frame>
to be available and switch to it.<frame>
to be available and switch to it.You can use the following solution:
Code Block:
WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.NAME,"name")))
WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"frame[name='mid1']")))
WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//frame[@name='mid2' and starts-with(@src, 'chkclineversion')]")))
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
You can find a relevant discussion in How to locate and click on an element which is nested within multiple frame and frameset through Selenium using Webdriver and C#