I'm unable to locate the frame - tabFrame from the attached screenshot, whereas I was able to locate outlookFrame. I used:
driver.switch_to.frame('outlookFrame')
But when I use:
driver.switch_to.frame('tabFrame')
It doesn't work.
I'm unable to locate the frame - tabFrame from the attached screenshot, whereas I was able to locate outlookFrame. I used:
driver.switch_to.frame('outlookFrame')
But when I use:
driver.switch_to.frame('tabFrame')
It doesn't work.
As the desired elements is within nested <iframe>
elements so you have to:
Induce WebDriverWait for the parent frame to be available and switch to it.
Induce WebDriverWait for the child frame to be available and switch to it.
Induce WebDriverWait for the desired element to be clickable.
You can use either of the following locator strategies:
Using CSS_SELECTOR
:
driver.get("http://web_page")
WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"outlookFrame_cssSelector")))
WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[name='tabFrame']")))
Using XPATH
:
driver.get("http://web_page")
WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"outlookFrame_xpath")))
WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[@name='tabFrame']")))
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 couple of relevant discussions in: